selenium-webdriver 4.4.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +86 -1
  3. data/LICENSE +1 -1
  4. data/NOTICE +1 -1
  5. data/bin/linux/selenium-manager +0 -0
  6. data/bin/macos/selenium-manager +0 -0
  7. data/bin/windows/selenium-manager.exe +0 -0
  8. data/lib/selenium/server.rb +20 -16
  9. data/lib/selenium/webdriver/atoms/findElements.js +0 -0
  10. data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
  11. data/lib/selenium/webdriver/atoms/isDisplayed.js +0 -0
  12. data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
  13. data/lib/selenium/webdriver/atoms.rb +2 -3
  14. data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
  15. data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
  16. data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
  17. data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
  18. data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
  19. data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
  20. data/lib/selenium/webdriver/bidi/log_inspector.rb +140 -0
  21. data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
  22. data/lib/selenium/webdriver/bidi/session.rb +13 -0
  23. data/lib/selenium/webdriver/bidi.rb +2 -1
  24. data/lib/selenium/webdriver/chrome/driver.rb +19 -28
  25. data/lib/selenium/webdriver/chrome/features.rb +5 -72
  26. data/lib/selenium/webdriver/chrome/options.rb +3 -237
  27. data/lib/selenium/webdriver/chrome/profile.rb +3 -83
  28. data/lib/selenium/webdriver/chrome/service.rb +4 -19
  29. data/lib/selenium/webdriver/chromium/driver.rb +61 -0
  30. data/lib/selenium/webdriver/chromium/features.rb +103 -0
  31. data/lib/selenium/webdriver/chromium/options.rb +261 -0
  32. data/lib/selenium/webdriver/chromium/profile.rb +113 -0
  33. data/lib/selenium/webdriver/chromium/service.rb +42 -0
  34. data/lib/selenium/webdriver/chromium.rb +32 -0
  35. data/lib/selenium/webdriver/common/action_builder.rb +11 -48
  36. data/lib/selenium/webdriver/common/child_process.rb +124 -0
  37. data/lib/selenium/webdriver/common/driver.rb +34 -25
  38. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
  39. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
  40. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
  41. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
  42. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
  43. data/lib/selenium/webdriver/common/driver_extensions/has_bidi.rb +0 -2
  44. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +0 -1
  45. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
  46. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +0 -2
  47. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
  48. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
  49. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
  50. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +1 -2
  51. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -1
  52. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
  53. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -2
  54. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
  55. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +0 -2
  56. data/lib/selenium/webdriver/common/element.rb +7 -7
  57. data/lib/selenium/webdriver/common/error.rb +0 -2
  58. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
  59. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +3 -3
  60. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +2 -2
  61. data/lib/selenium/webdriver/common/interactions/scroll.rb +7 -5
  62. data/lib/selenium/webdriver/common/logger.rb +10 -2
  63. data/lib/selenium/webdriver/common/options.rb +30 -8
  64. data/lib/selenium/webdriver/common/platform.rb +4 -1
  65. data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
  66. data/lib/selenium/webdriver/common/proxy.rb +1 -1
  67. data/lib/selenium/webdriver/common/selenium_manager.rb +89 -0
  68. data/lib/selenium/webdriver/common/service.rb +16 -8
  69. data/lib/selenium/webdriver/common/service_manager.rb +2 -10
  70. data/lib/selenium/webdriver/common/shadow_root.rb +1 -2
  71. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  72. data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
  73. data/lib/selenium/webdriver/common/target_locator.rb +2 -3
  74. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  75. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +8 -6
  76. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +0 -1
  77. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +16 -16
  78. data/lib/selenium/webdriver/common/websocket_connection.rb +10 -2
  79. data/lib/selenium/webdriver/common.rb +2 -0
  80. data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
  81. data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
  82. data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
  83. data/lib/selenium/webdriver/devtools/network_interceptor.rb +3 -6
  84. data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
  85. data/lib/selenium/webdriver/devtools/request.rb +0 -2
  86. data/lib/selenium/webdriver/devtools/response.rb +0 -2
  87. data/lib/selenium/webdriver/devtools.rb +0 -1
  88. data/lib/selenium/webdriver/edge/driver.rb +20 -3
  89. data/lib/selenium/webdriver/edge/features.rb +3 -4
  90. data/lib/selenium/webdriver/edge/options.rb +3 -5
  91. data/lib/selenium/webdriver/edge/profile.rb +2 -2
  92. data/lib/selenium/webdriver/edge/service.rb +2 -2
  93. data/lib/selenium/webdriver/firefox/driver.rb +19 -2
  94. data/lib/selenium/webdriver/firefox/features.rb +5 -2
  95. data/lib/selenium/webdriver/firefox/options.rb +6 -2
  96. data/lib/selenium/webdriver/firefox/profile.rb +6 -6
  97. data/lib/selenium/webdriver/firefox/service.rb +0 -1
  98. data/lib/selenium/webdriver/ie/driver.rb +20 -1
  99. data/lib/selenium/webdriver/ie/service.rb +1 -2
  100. data/lib/selenium/webdriver/remote/bridge.rb +8 -15
  101. data/lib/selenium/webdriver/remote/capabilities.rb +34 -12
  102. data/lib/selenium/webdriver/remote/commands.rb +0 -2
  103. data/lib/selenium/webdriver/remote/driver.rb +13 -13
  104. data/lib/selenium/webdriver/remote/http/curb.rb +0 -2
  105. data/lib/selenium/webdriver/remote/http/default.rb +1 -0
  106. data/lib/selenium/webdriver/remote/response.rb +0 -1
  107. data/lib/selenium/webdriver/safari/driver.rb +20 -1
  108. data/lib/selenium/webdriver/safari/features.rb +0 -2
  109. data/lib/selenium/webdriver/safari/options.rb +5 -1
  110. data/lib/selenium/webdriver/safari.rb +1 -1
  111. data/lib/selenium/webdriver/support/color.rb +15 -15
  112. data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
  113. data/lib/selenium/webdriver/support/guards/guard_condition.rb +0 -2
  114. data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
  115. data/lib/selenium/webdriver/support/select.rb +3 -1
  116. data/lib/selenium/webdriver/version.rb +1 -1
  117. data/lib/selenium/webdriver.rb +3 -4
  118. data/selenium-webdriver.gemspec +8 -9
  119. metadata +29 -73
  120. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
  121. data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  class DevTools
23
23
  class PinnedScript
24
-
25
24
  attr_accessor :key, :devtools_identifier, :script
26
25
 
27
26
  def initialize(script)
@@ -52,7 +51,6 @@ module Selenium
52
51
  def remove
53
52
  "__webdriver_#{key} = undefined"
54
53
  end
55
-
56
54
  end # PinnedScript
57
55
  end # DevTools
58
56
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  class DevTools
23
23
  class Request
24
-
25
24
  attr_accessor :url, :method, :headers, :post_data
26
25
  attr_reader :id
27
26
 
@@ -60,7 +59,6 @@ module Selenium
60
59
  def inspect
61
60
  %(#<#{self.class.name} @id="#{id}" @method="#{method}" @url="#{url}")
62
61
  end
63
-
64
62
  end # Request
65
63
  end # DevTools
66
64
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  class DevTools
23
23
  class Response
24
-
25
24
  attr_accessor :code, :body, :headers
26
25
  attr_reader :id
27
26
 
@@ -59,7 +58,6 @@ module Selenium
59
58
  def inspect
60
59
  %(#<#{self.class.name} @id="#{id}" @code="#{code}")
61
60
  end
62
-
63
61
  end # Response
64
62
  end # DevTools
65
63
  end # WebDriver
@@ -81,7 +81,6 @@ module Selenium
81
81
  def error_message(error)
82
82
  [error['code'], error['message'], error['data']].join(': ')
83
83
  end
84
-
85
84
  end # DevTools
86
85
  end # WebDriver
87
86
  end # Selenium
@@ -17,18 +17,25 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/driver'
20
+ require 'selenium/webdriver/chromium/driver'
21
21
 
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Edge
25
-
26
25
  #
27
26
  # Driver implementation for Microsoft Edge.
28
27
  # @api private
29
28
  #
30
29
 
31
- class Driver < Selenium::WebDriver::Chrome::Driver
30
+ class Driver < Chromium::Driver
31
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
32
+ raise ArgumentError, "Can't initialize #{self.class} with :url" if url
33
+
34
+ caps = process_options(options, capabilities)
35
+ url = service_url(service || Service.edge)
36
+ super(caps: caps, url: url, **opts)
37
+ end
38
+
32
39
  def browser
33
40
  :edge
34
41
  end
@@ -38,6 +45,16 @@ module Selenium
38
45
  def devtools_address
39
46
  "http://#{capabilities['ms:edgeOptions']['debuggerAddress']}"
40
47
  end
48
+
49
+ def process_options(options, capabilities)
50
+ if options && !options.is_a?(Options)
51
+ raise ArgumentError, ":options must be an instance of #{Options}"
52
+ elsif options.nil? && capabilities.nil?
53
+ options = Options.new
54
+ end
55
+
56
+ super(options, capabilities)
57
+ end
41
58
  end # Driver
42
59
  end # Edge
43
60
  end # WebDriver
@@ -17,14 +17,13 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/features'
20
+ require 'selenium/webdriver/chromium/features'
21
21
 
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Edge
25
25
  module Features
26
-
27
- include WebDriver::Chrome::Features
26
+ include WebDriver::Chromium::Features
28
27
 
29
28
  EDGE_COMMANDS = {
30
29
  get_cast_sinks: [:get, 'session/:session_id/ms/cast/get_sinks'],
@@ -37,7 +36,7 @@ module Selenium
37
36
  }.freeze
38
37
 
39
38
  def commands(command)
40
- EDGE_COMMANDS[command] || Chrome::Features::CHROME_COMMANDS[command] || self.class::COMMANDS[command]
39
+ EDGE_COMMANDS[command] || CHROMIUM_COMMANDS[command] || self.class::COMMANDS[command]
41
40
  end
42
41
  end # Bridge
43
42
  end # Edge
@@ -17,23 +17,21 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/options'
20
+ require 'selenium/webdriver/chromium/options'
21
21
 
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Edge
25
- class Options < Selenium::WebDriver::Chrome::Options
25
+ class Options < Chromium::Options
26
26
  KEY = 'ms:edgeOptions'
27
27
  BROWSER = 'MicrosoftEdge'
28
28
 
29
- protected
29
+ private
30
30
 
31
31
  def enable_logging(browser_options)
32
32
  browser_options['ms:loggingPrefs'] = @logging_prefs
33
33
  end
34
34
 
35
- private
36
-
37
35
  def binary_path
38
36
  Edge.path
39
37
  end
@@ -17,7 +17,7 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/profile'
20
+ require 'selenium/webdriver/chromium/profile'
21
21
 
22
22
  module Selenium
23
23
  module WebDriver
@@ -26,7 +26,7 @@ module Selenium
26
26
  # @private
27
27
  #
28
28
 
29
- class Profile < Selenium::WebDriver::Chrome::Profile
29
+ class Profile < Chromium::Profile
30
30
  end # Profile
31
31
  end # Edge
32
32
  end # WebDriver
@@ -17,12 +17,12 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/service'
20
+ require 'selenium/webdriver/chromium/service'
21
21
 
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Edge
25
- class Service < Selenium::WebDriver::Chrome::Service
25
+ class Service < Chromium::Service
26
26
  DEFAULT_PORT = 9515
27
27
  EXECUTABLE = 'msedgedriver'
28
28
  MISSING_TEXT = <<~ERROR
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
-
24
23
  #
25
24
  # Driver implementation for Firefox using GeckoDriver.
26
25
  # @api private
@@ -37,6 +36,14 @@ module Selenium
37
36
  DriverExtensions::HasWebStorage,
38
37
  DriverExtensions::PrintsPage].freeze
39
38
 
39
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
40
+ raise ArgumentError, "Can't initialize #{self.class} with :url" if url
41
+
42
+ caps = process_options(options, capabilities)
43
+ url = service_url(service || Service.firefox)
44
+ super(caps: caps, url: url, **opts)
45
+ end
46
+
40
47
  def browser
41
48
  :firefox
42
49
  end
@@ -45,7 +52,7 @@ module Selenium
45
52
 
46
53
  def devtools_url
47
54
  if capabilities['moz:debuggerAddress'].nil?
48
- raise(Error::WebDriverError, "DevTools is not supported by this version of Firefox; use v85 or higher")
55
+ raise(Error::WebDriverError, 'DevTools is not supported by this version of Firefox; use v85 or higher')
49
56
  end
50
57
 
51
58
  uri = URI("http://#{capabilities['moz:debuggerAddress']}")
@@ -57,6 +64,16 @@ module Selenium
57
64
  def devtools_version
58
65
  Firefox::DEVTOOLS_VERSION
59
66
  end
67
+
68
+ def process_options(options, capabilities)
69
+ if options && !options.is_a?(Options)
70
+ raise ArgumentError, ":options must be an instance of #{Options}"
71
+ elsif options.nil? && capabilities.nil?
72
+ options = Options.new
73
+ end
74
+
75
+ super(options, capabilities)
76
+ end
60
77
  end # Driver
61
78
  end # Firefox
62
79
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
23
  module Features
24
-
25
24
  FIREFOX_COMMANDS = {
26
25
  get_context: [:get, 'session/:session_id/moz/context'],
27
26
  set_context: [:post, 'session/:session_id/moz/context'],
@@ -35,7 +34,11 @@ module Selenium
35
34
  end
36
35
 
37
36
  def install_addon(path, temporary)
38
- addon = File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
37
+ addon = if File.directory?(path)
38
+ Zipper.zip(path)
39
+ else
40
+ File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
41
+ end
39
42
 
40
43
  payload = {addon: addon}
41
44
  payload[:temporary] = temporary unless temporary.nil?
@@ -57,7 +57,8 @@ module Selenium
57
57
  #
58
58
 
59
59
  def initialize(log_level: nil, **opts)
60
- @debugger_address = opts.delete(:debugger_address)
60
+ @debugger_address = opts.delete(:debugger_address) { true }
61
+ opts[:accept_insecure_certs] = true unless opts.key?(:accept_insecure_certs)
61
62
 
62
63
  super(**opts)
63
64
 
@@ -107,6 +108,9 @@ module Selenium
107
108
  #
108
109
 
109
110
  def headless!
111
+ WebDriver.logger.deprecate('`Options#headless!`',
112
+ "`Options#add_argument('-headless')`",
113
+ id: :headless)
110
114
  add_argument '-headless'
111
115
  end
112
116
 
@@ -177,7 +181,7 @@ module Selenium
177
181
  end
178
182
 
179
183
  def camelize?(key)
180
- key != "prefs"
184
+ key != 'prefs'
181
185
  end
182
186
  end # Options
183
187
  end # Firefox
@@ -26,11 +26,11 @@ module Selenium
26
26
  VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
27
27
 
28
28
  DEFAULT_PREFERENCES = {
29
- "browser.newtabpage.enabled" => false,
30
- "browser.startup.homepage" => "about:blank",
31
- "browser.usedOnWindows10.introURL" => "about:blank",
32
- "network.captive-portal-service.enabled" => false,
33
- "security.csp.enable" => false
29
+ 'browser.newtabpage.enabled' => false,
30
+ 'browser.startup.homepage' => 'about:blank',
31
+ 'browser.usedOnWindows10.introURL' => 'about:blank',
32
+ 'network.captive-portal-service.enabled' => false,
33
+ 'security.csp.enable' => false
34
34
  }.freeze
35
35
 
36
36
  attr_reader :name, :log_file
@@ -143,7 +143,7 @@ module Selenium
143
143
  end
144
144
  end
145
145
 
146
- alias_method :as_json, :encoded
146
+ alias as_json encoded
147
147
 
148
148
  private
149
149
 
@@ -32,7 +32,6 @@ module Selenium
32
32
 
33
33
  private
34
34
 
35
- # NOTE: This processing is deprecated
36
35
  def extract_service_args(driver_opts)
37
36
  driver_args = super
38
37
  driver_opts = driver_opts.dup
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module IE
23
-
24
23
  #
25
24
  # Driver implementation for Internet Explorer supporting
26
25
  # both OSS and W3C dialects of JSON wire protocol.
@@ -30,9 +29,29 @@ module Selenium
30
29
  class Driver < WebDriver::Driver
31
30
  EXTENSIONS = [DriverExtensions::HasWebStorage].freeze
32
31
 
32
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
33
+ raise ArgumentError, "Can't initialize #{self.class} with :url" if url
34
+
35
+ caps = process_options(options, capabilities)
36
+ url = service_url(service || Service.ie)
37
+ super(caps: caps, url: url, **opts)
38
+ end
39
+
33
40
  def browser
34
41
  :internet_explorer
35
42
  end
43
+
44
+ private
45
+
46
+ def process_options(options, capabilities)
47
+ if options && !options.is_a?(Options)
48
+ raise ArgumentError, ":options must be an instance of #{Options}"
49
+ elsif options.nil? && capabilities.nil?
50
+ options = Options.new
51
+ end
52
+
53
+ super(options, capabilities)
54
+ end
36
55
  end # Driver
37
56
  end # IE
38
57
  end # WebDriver
@@ -32,7 +32,6 @@ module Selenium
32
32
 
33
33
  private
34
34
 
35
- # NOTE: This processing is deprecated
36
35
  def extract_service_args(driver_opts)
37
36
  driver_args = super
38
37
  driver_opts = driver_opts.dup
@@ -43,7 +42,7 @@ module Selenium
43
42
  end
44
43
  driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
45
44
  driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
46
- driver_args << "--silent" if driver_opts[:silent] == true
45
+ driver_args << '--silent' if driver_opts[:silent] == true
47
46
  driver_args
48
47
  end
49
48
  end # Server
@@ -186,6 +186,7 @@ module Selenium
186
186
  execute :delete_session
187
187
  http.close
188
188
  rescue *QUIT_ERRORS
189
+ nil
189
190
  end
190
191
 
191
192
  def close
@@ -367,18 +368,10 @@ module Selenium
367
368
  # actions
368
369
  #
369
370
 
370
- def action(deprecated_async = nil, async: false, devices: [], duration: 250)
371
- ActionBuilder.new self, nil, nil, deprecated_async, async: async, devices: devices, duration: duration
372
- end
373
- alias_method :actions, :action
374
-
375
- def mouse
376
- raise Error::UnsupportedOperationError, '#mouse is no longer supported, use #action instead'
377
- end
378
-
379
- def keyboard
380
- raise Error::UnsupportedOperationError, '#keyboard is no longer supported, use #action instead'
371
+ def action(async: false, devices: [], duration: 250)
372
+ ActionBuilder.new self, async: async, devices: devices, duration: duration
381
373
  end
374
+ alias actions action
382
375
 
383
376
  def send_actions(data)
384
377
  execute :actions, {}, {actions: data}
@@ -400,7 +393,7 @@ module Selenium
400
393
  # TODO: rework file detectors before Selenium 4.0
401
394
  if @file_detector
402
395
  local_files = keys.first&.split("\n")&.map { |key| @file_detector.call(Array(key)) }&.compact
403
- if local_files.any?
396
+ if local_files&.any?
404
397
  keys = local_files.map { |local_file| upload(local_file) }
405
398
  keys = Array(keys.join("\n"))
406
399
  end
@@ -425,7 +418,7 @@ module Selenium
425
418
  end
426
419
 
427
420
  def submit_element(element)
428
- script = "var form = arguments[0];\n" \
421
+ script = "/* submitForm */ var form = arguments[0];\n" \
429
422
  "while (form.nodeName != \"FORM\" && form.parentNode) {\n " \
430
423
  "form = form.parentNode;\n" \
431
424
  "}\n" \
@@ -437,7 +430,7 @@ module Selenium
437
430
 
438
431
  execute_script(script, Element::ELEMENT_KEY => element)
439
432
  rescue Error::JavascriptError
440
- raise Error::UnsupportedOperationError, "To submit an element, it must be nested inside a form element"
433
+ raise Error::UnsupportedOperationError, 'To submit an element, it must be nested inside a form element'
441
434
  end
442
435
 
443
436
  #
@@ -525,7 +518,7 @@ module Selenium
525
518
  Element.new self, element_id_from(execute(:get_active_element))
526
519
  end
527
520
 
528
- alias_method :switch_to_active_element, :active_element
521
+ alias switch_to_active_element active_element
529
522
 
530
523
  def find_element_by(how, what, parent_ref = [])
531
524
  how, what = convert_locator(how, what)
@@ -20,14 +20,12 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Remote
23
-
24
23
  #
25
24
  # Specification of the desired and/or actual capabilities of the browser that the
26
25
  # server is being asked to create.
27
26
  #
28
27
 
29
28
  class Capabilities
30
-
31
29
  KNOWN = [
32
30
  :browser_name,
33
31
  :browser_version,
@@ -59,10 +57,25 @@ module Selenium
59
57
  # Backward compatibility
60
58
  #
61
59
 
62
- alias_method :version, :browser_version
63
- alias_method :version=, :browser_version=
64
- alias_method :platform, :platform_name
65
- alias_method :platform=, :platform_name=
60
+ def version
61
+ WebDriver.logger.deprecate('`Capabilities#version`', '`Capabilities#browser_version`', id: :jwp_caps)
62
+ browser_version
63
+ end
64
+
65
+ def version=(value)
66
+ WebDriver.logger.deprecate('`Capabilities#version=`', '`Capabilities#browser_version=`', id: :jwp_caps)
67
+ self.browser_version = value
68
+ end
69
+
70
+ def platform
71
+ WebDriver.logger.deprecate('`Capabilities#platform`', '`Capabilities#platform_name`', id: :jwp_caps)
72
+ platform_name
73
+ end
74
+
75
+ def platform=(value)
76
+ WebDriver.logger.deprecate('`Capabilities#platform=`', '`Capabilities#platform_name=`', id: :jwp_caps)
77
+ self.platform_name = value
78
+ end
66
79
 
67
80
  #
68
81
  # Convenience methods for the common choices.
@@ -70,44 +83,52 @@ module Selenium
70
83
 
71
84
  class << self
72
85
  def chrome(opts = {})
86
+ WebDriver.logger.deprecate('Remote::Capabilities.chrome', 'Options.chrome', id: :caps_browsers)
73
87
  new({
74
88
  browser_name: 'chrome'
75
89
  }.merge(opts))
76
90
  end
77
91
 
78
92
  def edge(opts = {})
93
+ WebDriver.logger.deprecate('Remote::Capabilities.edge', 'Options.edge', id: :caps_browsers)
79
94
  new({
80
95
  browser_name: 'MicrosoftEdge'
81
96
  }.merge(opts))
82
97
  end
83
- alias_method :microsoftedge, :edge
98
+ alias microsoftedge edge
84
99
 
85
100
  def firefox(opts = {})
101
+ WebDriver.logger.deprecate('Remote::Capabilities.firefox', 'Options.firefox', id: :caps_browsers)
86
102
  new({
87
103
  browser_name: 'firefox'
88
104
  }.merge(opts))
89
105
  end
90
- alias_method :ff, :firefox
106
+ alias ff firefox
91
107
 
92
108
  def safari(opts = {})
109
+ WebDriver.logger.deprecate('Remote::Capabilities.safari', 'Options.safari', id: :caps_browsers)
93
110
  new({
94
- browser_name: Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
111
+ browser_name: Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
95
112
  }.merge(opts))
96
113
  end
97
114
 
98
115
  def htmlunit(opts = {})
116
+ WebDriver.logger.deprecate('Remote::Capabilities.htmlunit',
117
+ 'as argument in constructor',
118
+ id: :caps_browsers)
99
119
  new({
100
120
  browser_name: 'htmlunit'
101
121
  }.merge(opts))
102
122
  end
103
123
 
104
124
  def internet_explorer(opts = {})
125
+ WebDriver.logger.deprecate('Remote::Capabilities.ie', 'Options.ie', id: :caps_browsers)
105
126
  new({
106
127
  browser_name: 'internet explorer',
107
128
  platform_name: :windows
108
129
  }.merge(opts))
109
130
  end
110
- alias_method :ie, :internet_explorer
131
+ alias ie internet_explorer
111
132
 
112
133
  def always_match(capabilities)
113
134
  new(always_match: capabilities)
@@ -134,7 +155,8 @@ module Selenium
134
155
 
135
156
  # Remote Server Specific
136
157
  if data.key?('webdriver.remote.sessionid')
137
- caps[:remote_session_id] = data.delete('webdriver.remote.sessionid')
158
+ caps[:remote_session_id] =
159
+ data.delete('webdriver.remote.sessionid')
138
160
  end
139
161
 
140
162
  KNOWN.each do |cap|
@@ -269,7 +291,7 @@ module Selenium
269
291
  as_json == other.as_json
270
292
  end
271
293
 
272
- alias_method :eql?, :==
294
+ alias eql? ==
273
295
 
274
296
  protected
275
297
 
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Remote
23
-
24
23
  #
25
24
  # https://w3c.github.io/webdriver/#endpoints
26
25
  # @api private
@@ -165,7 +164,6 @@ module Selenium
165
164
  set_user_verified: [:post, 'session/:session_id/webauthn/authenticator/:authenticatorId/uv']
166
165
 
167
166
  }.freeze
168
-
169
167
  end # Bridge
170
168
  end # Remote
171
169
  end # WebDriver
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Remote
23
-
24
23
  #
25
24
  # Driver implementation for remote server.
26
25
  # @api private
@@ -30,17 +29,12 @@ module Selenium
30
29
  include DriverExtensions::UploadsFiles
31
30
  include DriverExtensions::HasSessionId
32
31
 
33
- def initialize(bridge: nil, listener: nil, **opts)
34
- desired_capabilities = opts[:desired_capabilities]
35
- if desired_capabilities.is_a?(Symbol)
36
- unless Remote::Capabilities.respond_to?(desired_capabilities)
37
- raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
38
- end
39
-
40
- opts[:desired_capabilities] = Remote::Capabilities.__send__(desired_capabilities)
41
- end
42
- opts[:url] ||= "http://#{Platform.localhost}:4444/wd/hub"
43
- super
32
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
33
+ raise ArgumentError, "Can not set :service object on #{self.class}" if service
34
+
35
+ url ||= "http://#{Platform.localhost}:4444/wd/hub"
36
+ caps = process_options(options, capabilities)
37
+ super(caps: caps, url: url, **opts)
44
38
  @bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s }
45
39
  end
46
40
 
@@ -52,7 +46,13 @@ module Selenium
52
46
 
53
47
  def devtools_version
54
48
  capabilities['se:cdpVersion']&.split('.')&.first ||
55
- raise(Error::WebDriverError, "DevTools is not supported by the Remote Server")
49
+ raise(Error::WebDriverError, 'DevTools is not supported by the Remote Server')
50
+ end
51
+
52
+ def process_options(options, capabilities)
53
+ raise ArgumentError, "#{self.class} needs :options to be set" if options.nil? && capabilities.nil?
54
+
55
+ super(options, capabilities)
56
56
  end
57
57
  end # Driver
58
58
  end # Remote
@@ -22,7 +22,6 @@ require 'curb'
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Remote
25
-
26
25
  module Http
27
26
  #
28
27
  # An alternative to the default Net::HTTP client.
@@ -38,7 +37,6 @@ module Selenium
38
37
  #
39
38
 
40
39
  class Curb < Common
41
-
42
40
  def quit_errors
43
41
  [Curl::Err::RecvError] + super
44
42
  end
@@ -100,6 +100,7 @@ module Selenium
100
100
 
101
101
  request(:get, URI.parse(response['Location']), DEFAULT_HEADERS.dup, nil, redirects + 1)
102
102
  else
103
+ WebDriver.logger.debug(" <<< #{response.instance_variable_get(:@header).inspect}")
103
104
  create_response response.code, response.body, response.content_type
104
105
  end
105
106
  end
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Remote
23
-
24
23
  #
25
24
  # @api private
26
25
  #