selenium-webdriver 3.0.0.beta4.0 → 4.0.0.alpha5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +679 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/lib/selenium-webdriver.rb +2 -2
  7. data/lib/selenium/server.rb +23 -16
  8. data/lib/selenium/webdriver.rb +43 -25
  9. data/lib/selenium/webdriver/atoms.rb +20 -1
  10. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  11. data/lib/selenium/webdriver/atoms/getAttribute.js +84 -11
  12. data/lib/selenium/webdriver/atoms/isDisplayed.js +100 -0
  13. data/lib/selenium/webdriver/chrome.rb +15 -20
  14. data/lib/selenium/webdriver/chrome/bridge.rb +29 -66
  15. data/lib/selenium/webdriver/{edge/service.rb → chrome/driver.rb} +19 -22
  16. data/lib/selenium/webdriver/chrome/options.rb +221 -0
  17. data/lib/selenium/webdriver/chrome/profile.rb +6 -7
  18. data/lib/selenium/webdriver/chrome/service.rb +20 -20
  19. data/lib/selenium/webdriver/common.rb +19 -11
  20. data/lib/selenium/webdriver/common/action_builder.rb +98 -246
  21. data/lib/selenium/webdriver/common/alert.rb +2 -7
  22. data/lib/selenium/webdriver/common/driver.rb +89 -51
  23. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +12 -25
  26. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +38 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -5
  28. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -3
  30. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -2
  32. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -2
  33. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -2
  34. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -4
  35. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -3
  36. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -5
  37. data/lib/selenium/webdriver/common/element.rb +32 -10
  38. data/lib/selenium/webdriver/common/error.rb +103 -121
  39. data/lib/selenium/webdriver/common/file_reaper.rb +3 -5
  40. data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -2
  41. data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -2
  42. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +3 -2
  43. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  44. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  45. data/lib/selenium/webdriver/{phantomjs.rb → common/interactions/interactions.rb} +17 -20
  46. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  47. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  48. data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
  49. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  50. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  51. data/lib/selenium/webdriver/common/keys.rb +37 -15
  52. data/lib/selenium/webdriver/common/log_entry.rb +4 -4
  53. data/lib/selenium/webdriver/common/logger.rb +147 -0
  54. data/lib/selenium/webdriver/common/logs.rb +2 -2
  55. data/lib/selenium/webdriver/common/manager.rb +177 -0
  56. data/lib/selenium/webdriver/common/navigation.rb +2 -2
  57. data/lib/selenium/webdriver/common/options.rb +47 -105
  58. data/lib/selenium/webdriver/common/platform.rb +44 -38
  59. data/lib/selenium/webdriver/common/port_prober.rb +8 -19
  60. data/lib/selenium/webdriver/common/profile_helper.rb +13 -5
  61. data/lib/selenium/webdriver/common/proxy.rb +14 -8
  62. data/lib/selenium/webdriver/common/search_context.rb +16 -20
  63. data/lib/selenium/webdriver/common/service.rb +115 -30
  64. data/lib/selenium/webdriver/common/socket_lock.rb +12 -7
  65. data/lib/selenium/webdriver/common/socket_poller.rb +29 -22
  66. data/lib/selenium/webdriver/common/target_locator.rb +6 -6
  67. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  68. data/lib/selenium/webdriver/common/wait.rb +14 -8
  69. data/lib/selenium/webdriver/common/window.rb +38 -2
  70. data/lib/selenium/webdriver/common/zipper.rb +3 -5
  71. data/lib/selenium/webdriver/edge.rb +33 -20
  72. data/lib/selenium/webdriver/edge_chrome/bridge.rb +30 -0
  73. data/lib/selenium/webdriver/edge_chrome/driver.rb +38 -0
  74. data/lib/selenium/webdriver/{common/driver_extensions/has_touch_screen.rb → edge_chrome/options.rb} +10 -12
  75. data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
  76. data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
  77. data/lib/selenium/webdriver/edge_html/driver.rb +39 -0
  78. data/lib/selenium/webdriver/edge_html/options.rb +91 -0
  79. data/lib/selenium/webdriver/edge_html/service.rb +47 -0
  80. data/lib/selenium/webdriver/firefox.rb +24 -29
  81. data/lib/selenium/webdriver/firefox/bridge.rb +15 -39
  82. data/lib/selenium/webdriver/firefox/{util.rb → driver.rb} +13 -19
  83. data/lib/selenium/webdriver/firefox/extension.rb +28 -8
  84. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  85. data/lib/selenium/webdriver/firefox/profile.rb +23 -82
  86. data/lib/selenium/webdriver/firefox/profiles_ini.rb +5 -5
  87. data/lib/selenium/webdriver/firefox/service.rb +18 -37
  88. data/lib/selenium/webdriver/ie.rb +13 -19
  89. data/lib/selenium/webdriver/ie/driver.rb +40 -0
  90. data/lib/selenium/webdriver/ie/options.rb +118 -0
  91. data/lib/selenium/webdriver/ie/service.rb +20 -20
  92. data/lib/selenium/webdriver/remote.rb +15 -17
  93. data/lib/selenium/webdriver/remote/bridge.rb +281 -300
  94. data/lib/selenium/webdriver/remote/capabilities.rb +102 -83
  95. data/lib/selenium/webdriver/remote/commands.rb +132 -192
  96. data/lib/selenium/webdriver/remote/driver.rb +52 -0
  97. data/lib/selenium/webdriver/remote/http/common.rb +23 -13
  98. data/lib/selenium/webdriver/remote/http/curb.rb +10 -7
  99. data/lib/selenium/webdriver/remote/http/default.rb +52 -32
  100. data/lib/selenium/webdriver/remote/http/persistent.rb +8 -4
  101. data/lib/selenium/webdriver/remote/response.rb +32 -35
  102. data/lib/selenium/webdriver/remote/server_error.rb +2 -2
  103. data/lib/selenium/webdriver/safari.rb +24 -22
  104. data/lib/selenium/webdriver/safari/bridge.rb +21 -21
  105. data/lib/selenium/webdriver/safari/driver.rb +41 -0
  106. data/lib/selenium/webdriver/safari/options.rb +66 -0
  107. data/lib/selenium/webdriver/safari/service.rb +8 -24
  108. data/lib/selenium/webdriver/support.rb +3 -2
  109. data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -2
  110. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -3
  111. data/lib/selenium/webdriver/support/color.rb +13 -13
  112. data/lib/selenium/webdriver/support/escaper.rb +2 -2
  113. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  114. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  115. data/lib/selenium/webdriver/support/select.rb +20 -21
  116. data/lib/selenium/webdriver/version.rb +24 -0
  117. data/selenium-webdriver.gemspec +31 -17
  118. metadata +331 -248
  119. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  120. data/lib/selenium/webdriver/common/keyboard.rb +0 -69
  121. data/lib/selenium/webdriver/common/mouse.rb +0 -88
  122. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -81
  123. data/lib/selenium/webdriver/common/touch_screen.rb +0 -121
  124. data/lib/selenium/webdriver/common/w3c_error.rb +0 -191
  125. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  126. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  127. data/lib/selenium/webdriver/firefox/binary.rb +0 -186
  128. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  129. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  130. data/lib/selenium/webdriver/firefox/launcher.rb +0 -114
  131. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  132. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  133. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +0 -79
  134. data/lib/selenium/webdriver/ie/bridge.rb +0 -76
  135. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -65
  136. data/lib/selenium/webdriver/phantomjs/service.rb +0 -66
  137. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -682
  138. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -228
  139. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -135
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ require 'selenium/webdriver/chrome/profile'
21
+
22
+ module Selenium
23
+ module WebDriver
24
+ module EdgeChrome
25
+ #
26
+ # @private
27
+ #
28
+
29
+ class Profile < Selenium::WebDriver::Chrome::Profile
30
+ end # Profile
31
+ end # EdgeChrome
32
+ end # WebDriver
33
+ end # Selenium
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ require 'selenium/webdriver/chrome/service'
21
+
22
+ module Selenium
23
+ module WebDriver
24
+ module EdgeChrome
25
+ class Service < Selenium::WebDriver::Chrome::Service
26
+ DEFAULT_PORT = 9515
27
+ EXECUTABLE = 'msedgedriver'
28
+ MISSING_TEXT = <<~ERROR
29
+ Unable to find msedgedriver. Please download the server from
30
+ https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ and place it somewhere on your PATH.
31
+ ERROR
32
+ SHUTDOWN_SUPPORTED = true
33
+ end # Service
34
+ end # EdgeChrome
35
+ end # WebDriver
36
+ end # Selenium
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module EdgeHtml
23
+
24
+ #
25
+ # Driver implementation for Microsoft Edge.
26
+ # @api private
27
+ #
28
+
29
+ class Driver < WebDriver::Driver
30
+ include DriverExtensions::HasWebStorage
31
+ include DriverExtensions::TakesScreenshot
32
+
33
+ def browser
34
+ :edge
35
+ end
36
+ end # Driver
37
+ end # EdgeHtml
38
+ end # WebDriver
39
+ end # Selenium
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module EdgeHtml
23
+ class Options < WebDriver::Options
24
+ # see https://docs.microsoft.com/en-us/microsoft-edge/webdriver#capabilities
25
+ CAPABILITIES = {in_private: 'ms:inPrivate',
26
+ extension_paths: 'ms:extensionPaths',
27
+ start_page: 'ms:startPage'}.freeze
28
+
29
+ CAPABILITIES.each_key do |key|
30
+ define_method key do
31
+ @options[key]
32
+ end
33
+
34
+ define_method "#{key}=" do |value|
35
+ @options[key] = value
36
+ end
37
+ end
38
+
39
+ #
40
+ # Create a new Options instance for Edge.
41
+ #
42
+ # @example
43
+ # options = Selenium::WebDriver::Edge::Options.new(in_private: true)
44
+ # driver = Selenium::WebDriver.for :edge, options: options
45
+ #
46
+ # @param [Hash] opts the pre-defined options to create the Edge::Options with
47
+ # @option opts [Boolean] :in_private Start in private mode. Default is false
48
+ # @option opts [Array<String>] :extension_paths A list of full paths to extensions to install on startup
49
+ # @option opts [String] :start_page Default page to start with
50
+ #
51
+ # @see https://docs.microsoft.com/en-us/microsoft-edge/webdriver
52
+ #
53
+
54
+ def initialize(**opts)
55
+ super
56
+ @options[:extensions]&.each(&method(:validate_extension))
57
+ end
58
+
59
+ #
60
+ # Add an extension by local path.
61
+ #
62
+ # @example
63
+ # options = Selenium::WebDriver::Edge::Options.new
64
+ # options.add_extension_path('C:\path\to\extension')
65
+ #
66
+ # @param [String] path The local path to the extension folder
67
+ #
68
+
69
+ def add_extension_path(path)
70
+ validate_extension(path)
71
+ @options[:extension_paths] ||= []
72
+ @options[:extension_paths] << path
73
+ end
74
+
75
+ #
76
+ # @api private
77
+ #
78
+
79
+ def as_json(*)
80
+ generate_as_json(super)
81
+ end
82
+
83
+ private
84
+
85
+ def validate_extension(path)
86
+ raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.directory?(path)
87
+ end
88
+ end # Options
89
+ end # EdgeHtml
90
+ end # WebDriver
91
+ end # Selenium
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module EdgeHtml
23
+ class Service < WebDriver::Service
24
+ DEFAULT_PORT = 17556
25
+ EXECUTABLE = 'MicrosoftWebDriver'
26
+ MISSING_TEXT = <<~ERROR
27
+ Unable to find MicrosoftWebDriver. Please install it following instructions
28
+ at https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/.
29
+ ERROR
30
+ SHUTDOWN_SUPPORTED = false
31
+
32
+ private
33
+
34
+ # Note: This processing is deprecated
35
+ def extract_service_args(driver_opts)
36
+ driver_args = super
37
+ driver_opts = driver_opts.dup
38
+ driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key? :host
39
+ driver_args << "--package=#{driver_opts[:package]}" if driver_opts.key? :package
40
+ driver_args << "--silent" if driver_opts[:silent] == true
41
+ driver_args << "--verbose" if driver_opts[:verbose] == true
42
+ driver_args
43
+ end
44
+ end # Service
45
+ end # EdgeHtml
46
+ end # WebDriver
47
+ end # Service
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -21,49 +21,44 @@ require 'timeout'
21
21
  require 'socket'
22
22
  require 'rexml/document'
23
23
 
24
- require 'selenium/webdriver/firefox/util'
25
- require 'selenium/webdriver/firefox/extension'
26
- require 'selenium/webdriver/firefox/binary'
27
- require 'selenium/webdriver/firefox/profiles_ini'
28
- require 'selenium/webdriver/firefox/profile'
29
- require 'selenium/webdriver/firefox/launcher'
30
- require 'selenium/webdriver/firefox/bridge'
31
- require 'selenium/webdriver/firefox/w3c_bridge'
32
- require 'selenium/webdriver/firefox/binary'
33
- require 'selenium/webdriver/firefox/service'
34
-
35
24
  module Selenium
36
25
  module WebDriver
37
26
  module Firefox
27
+ autoload :Extension, 'selenium/webdriver/firefox/extension'
28
+ autoload :ProfilesIni, 'selenium/webdriver/firefox/profiles_ini'
29
+ autoload :Profile, 'selenium/webdriver/firefox/profile'
30
+ autoload :Bridge, 'selenium/webdriver/firefox/bridge'
31
+ autoload :Driver, 'selenium/webdriver/firefox/driver'
32
+ autoload :Options, 'selenium/webdriver/firefox/options'
33
+ autoload :Service, 'selenium/webdriver/firefox/service'
34
+
38
35
  DEFAULT_PORT = 7055
39
36
  DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows
40
37
  DEFAULT_SECURE_SSL = false
41
38
  DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
42
39
  DEFAULT_LOAD_NO_FOCUS_LIB = false
43
40
 
44
- MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
45
- Unable to find Mozilla geckodriver. Please download the server from
46
- https://github.com/mozilla/geckodriver/releases and place it
47
- somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
48
- ERROR
49
-
50
41
  def self.driver_path=(path)
51
- Platform.assert_executable path
52
- @driver_path = path
42
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path=',
43
+ 'Selenium::WebDriver::Firefox::Service#driver_path=',
44
+ id: :driver_path
45
+ Selenium::WebDriver::Firefox::Service.driver_path = path
53
46
  end
54
47
 
55
48
  def self.driver_path
56
- @driver_path ||= begin
57
- path = Platform.find_binary('geckodriver*')
58
- raise Error::WebDriverError, MISSING_TEXT unless path
59
- Platform.assert_executable path
60
-
61
- path
62
- end
49
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path',
50
+ 'Selenium::WebDriver::Firefox::Service#driver_path',
51
+ id: :driver_path
52
+ Selenium::WebDriver::Firefox::Service.driver_path
63
53
  end
64
54
 
65
55
  def self.path=(path)
66
- Binary.path = path
56
+ Platform.assert_executable path
57
+ @path = path
58
+ end
59
+
60
+ def self.path
61
+ @path ||= nil
67
62
  end
68
63
  end # Firefox
69
64
  end # WebDriver
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,51 +20,27 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
- # @api private
24
- class Bridge < Remote::Bridge
25
- def initialize(opts = {})
26
- port = opts.delete(:port) || DEFAULT_PORT
27
- profile = opts.delete(:profile)
23
+ module Bridge
28
24
 
29
- @launcher = create_launcher(port, profile)
30
- @launcher.launch
31
- opts[:url] = @launcher.url
25
+ COMMANDS = {
26
+ install_addon: [:post, 'session/:session_id/moz/addon/install'],
27
+ uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
28
+ }.freeze
32
29
 
33
- caps = opts[:desired_capabilities] ||= Remote::Capabilities.firefox
34
- caps.proxy = opts.delete(:proxy) if opts.key?(:proxy)
35
- Binary.path = caps[:firefox_binary] if caps[:firefox_binary]
36
-
37
- begin
38
- super(opts)
39
- rescue
40
- @launcher.quit
41
- raise
42
- end
30
+ def commands(command)
31
+ COMMANDS[command] || super
43
32
  end
44
33
 
45
- def browser
46
- :firefox
34
+ def install_addon(path, temporary)
35
+ payload = {path: path}
36
+ payload[:temporary] = temporary unless temporary.nil?
37
+ execute :install_addon, {}, payload
47
38
  end
48
39
 
49
- def driver_extensions
50
- [
51
- DriverExtensions::TakesScreenshot,
52
- DriverExtensions::HasInputDevices
53
- ]
40
+ def uninstall_addon(id)
41
+ execute :uninstall_addon, {}, {id: id}
54
42
  end
55
43
 
56
- def quit
57
- super
58
- nil
59
- ensure
60
- @launcher.quit
61
- end
62
-
63
- private
64
-
65
- def create_launcher(port, profile)
66
- Launcher.new Binary.new, port, profile
67
- end
68
44
  end # Bridge
69
45
  end # Firefox
70
46
  end # WebDriver
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,27 +20,21 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
+
24
+ #
25
+ # Driver implementation for Firefox using GeckoDriver.
23
26
  # @api private
24
- module Util
25
- module_function
27
+ #
26
28
 
27
- def app_data_path
28
- case Platform.os
29
- when :windows
30
- "#{ENV['APPDATA']}\\Mozilla\\Firefox"
31
- when :macosx
32
- "#{Platform.home}/Library/Application Support/Firefox"
33
- when :unix, :linux
34
- "#{Platform.home}/.mozilla/firefox"
35
- else
36
- raise "Unknown os: #{Platform.os}"
37
- end
38
- end
29
+ class Driver < WebDriver::Driver
30
+ include DriverExtensions::HasAddons
31
+ include DriverExtensions::HasWebStorage
32
+ include DriverExtensions::TakesScreenshot
39
33
 
40
- def stringified?(str)
41
- str =~ /^".*"$/
34
+ def browser
35
+ :firefox
42
36
  end
43
- end # Util
37
+ end # Driver
44
38
  end # Firefox
45
39
  end # WebDriver
46
40
  end # Selenium