selenium-webdriver 4.7.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +34 -0
  3. data/LICENSE +1 -1
  4. data/NOTICE +1 -1
  5. data/lib/selenium/server.rb +1 -0
  6. data/lib/selenium/webdriver/atoms.rb +2 -3
  7. data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
  8. data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
  9. data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
  10. data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
  11. data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
  12. data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
  13. data/lib/selenium/webdriver/bidi/log_inspector.rb +140 -0
  14. data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
  15. data/lib/selenium/webdriver/bidi/session.rb +13 -0
  16. data/lib/selenium/webdriver/bidi.rb +2 -1
  17. data/lib/selenium/webdriver/chrome/driver.rb +19 -29
  18. data/lib/selenium/webdriver/chrome/features.rb +5 -72
  19. data/lib/selenium/webdriver/chrome/options.rb +3 -237
  20. data/lib/selenium/webdriver/chrome/profile.rb +3 -83
  21. data/lib/selenium/webdriver/chrome/service.rb +3 -18
  22. data/lib/selenium/webdriver/chromium/driver.rb +61 -0
  23. data/lib/selenium/webdriver/chromium/features.rb +103 -0
  24. data/lib/selenium/webdriver/chromium/options.rb +261 -0
  25. data/lib/selenium/webdriver/chromium/profile.rb +113 -0
  26. data/lib/selenium/webdriver/chromium/service.rb +42 -0
  27. data/lib/selenium/webdriver/chromium.rb +32 -0
  28. data/lib/selenium/webdriver/common/action_builder.rb +11 -48
  29. data/lib/selenium/webdriver/common/child_process.rb +0 -2
  30. data/lib/selenium/webdriver/common/driver.rb +34 -25
  31. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
  32. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
  33. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
  34. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
  35. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
  36. data/lib/selenium/webdriver/common/driver_extensions/has_bidi.rb +0 -2
  37. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +0 -1
  38. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
  39. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +0 -2
  40. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
  41. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
  42. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
  43. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +1 -2
  44. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -1
  45. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
  46. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -2
  47. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
  48. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +0 -2
  49. data/lib/selenium/webdriver/common/element.rb +6 -6
  50. data/lib/selenium/webdriver/common/error.rb +0 -2
  51. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
  52. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +3 -3
  53. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +2 -2
  54. data/lib/selenium/webdriver/common/interactions/scroll.rb +7 -5
  55. data/lib/selenium/webdriver/common/logger.rb +10 -2
  56. data/lib/selenium/webdriver/common/options.rb +30 -8
  57. data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
  58. data/lib/selenium/webdriver/common/proxy.rb +1 -1
  59. data/lib/selenium/webdriver/common/selenium_manager.rb +10 -12
  60. data/lib/selenium/webdriver/common/service.rb +9 -5
  61. data/lib/selenium/webdriver/common/service_manager.rb +1 -1
  62. data/lib/selenium/webdriver/common/shadow_root.rb +1 -2
  63. data/lib/selenium/webdriver/common/socket_lock.rb +1 -0
  64. data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
  65. data/lib/selenium/webdriver/common/target_locator.rb +2 -3
  66. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  67. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +8 -6
  68. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +0 -1
  69. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +16 -16
  70. data/lib/selenium/webdriver/common/websocket_connection.rb +1 -2
  71. data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
  72. data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
  73. data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
  74. data/lib/selenium/webdriver/devtools/network_interceptor.rb +3 -6
  75. data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
  76. data/lib/selenium/webdriver/devtools/request.rb +0 -2
  77. data/lib/selenium/webdriver/devtools/response.rb +0 -2
  78. data/lib/selenium/webdriver/devtools.rb +0 -1
  79. data/lib/selenium/webdriver/edge/driver.rb +20 -3
  80. data/lib/selenium/webdriver/edge/features.rb +3 -4
  81. data/lib/selenium/webdriver/edge/options.rb +3 -5
  82. data/lib/selenium/webdriver/edge/profile.rb +2 -2
  83. data/lib/selenium/webdriver/edge/service.rb +2 -2
  84. data/lib/selenium/webdriver/firefox/driver.rb +19 -2
  85. data/lib/selenium/webdriver/firefox/features.rb +0 -1
  86. data/lib/selenium/webdriver/firefox/options.rb +4 -1
  87. data/lib/selenium/webdriver/firefox/profile.rb +6 -6
  88. data/lib/selenium/webdriver/firefox/service.rb +0 -1
  89. data/lib/selenium/webdriver/ie/driver.rb +20 -1
  90. data/lib/selenium/webdriver/ie/service.rb +1 -2
  91. data/lib/selenium/webdriver/remote/bridge.rb +8 -15
  92. data/lib/selenium/webdriver/remote/capabilities.rb +34 -12
  93. data/lib/selenium/webdriver/remote/commands.rb +0 -2
  94. data/lib/selenium/webdriver/remote/driver.rb +13 -13
  95. data/lib/selenium/webdriver/remote/http/curb.rb +0 -2
  96. data/lib/selenium/webdriver/remote/http/default.rb +1 -0
  97. data/lib/selenium/webdriver/remote/response.rb +0 -1
  98. data/lib/selenium/webdriver/safari/driver.rb +20 -1
  99. data/lib/selenium/webdriver/safari/features.rb +0 -2
  100. data/lib/selenium/webdriver/safari/options.rb +5 -1
  101. data/lib/selenium/webdriver/safari.rb +1 -1
  102. data/lib/selenium/webdriver/support/color.rb +15 -15
  103. data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
  104. data/lib/selenium/webdriver/support/guards/guard_condition.rb +0 -2
  105. data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
  106. data/lib/selenium/webdriver/version.rb +1 -1
  107. data/lib/selenium/webdriver.rb +3 -3
  108. data/selenium-webdriver.gemspec +3 -5
  109. metadata +25 -41
  110. data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
  111. data/lib/selenium/webdriver/support/nightly_version_generator.rb +0 -60
@@ -51,7 +51,7 @@ module Selenium
51
51
  Safari::Driver.new(**opts)
52
52
  when :firefox, :ff
53
53
  Firefox::Driver.new(**opts)
54
- when :edge
54
+ when :edge, :microsoftedge, :msedge
55
55
  Edge::Driver.new(**opts)
56
56
  when :remote
57
57
  Remote::Driver.new(**opts)
@@ -69,7 +69,7 @@ module Selenium
69
69
  #
70
70
 
71
71
  def initialize(bridge: nil, listener: nil, **opts)
72
- @service = nil
72
+ @service_manager = nil
73
73
  @devtools = nil
74
74
  bridge ||= create_bridge(**opts)
75
75
  add_extensions(bridge.browser)
@@ -127,14 +127,6 @@ module Selenium
127
127
  bridge.action(**opts)
128
128
  end
129
129
 
130
- def mouse
131
- bridge.mouse
132
- end
133
-
134
- def keyboard
135
- bridge.keyboard
136
- end
137
-
138
130
  #
139
131
  # Opens the specified URL in the browser.
140
132
  #
@@ -180,7 +172,7 @@ module Selenium
180
172
  def quit
181
173
  bridge.quit
182
174
  ensure
183
- @service&.stop
175
+ @service_manager&.stop
184
176
  @devtools&.close
185
177
  end
186
178
 
@@ -263,19 +255,19 @@ module Selenium
263
255
  # driver.first(id: 'foo')
264
256
  #
265
257
 
266
- alias_method :first, :find_element
258
+ alias first find_element
267
259
 
268
260
  #
269
261
  # driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
270
262
  #
271
263
 
272
- alias_method :all, :find_elements
264
+ alias all find_elements
273
265
 
274
266
  #
275
267
  # driver.script('function() { ... };')
276
268
  #
277
269
 
278
- alias_method :script, :execute_script
270
+ alias script execute_script
279
271
 
280
272
  # Get the first element matching the given selector. If given a
281
273
  # String or Symbol, it will be used as the id of the element.
@@ -316,30 +308,45 @@ module Selenium
316
308
 
317
309
  attr_reader :bridge
318
310
 
319
- def create_bridge(capabilities: nil, options: nil, url: nil, service: nil, http_client: nil)
320
- Remote::Bridge.new(http_client: http_client,
321
- url: url || service_url(service)).tap do |bridge|
322
- generated_caps = options ? options.as_json : generate_capabilities(capabilities)
323
- bridge.create_session(generated_caps)
311
+ def create_bridge(caps:, url:, http_client: nil)
312
+ Remote::Bridge.new(http_client: http_client, url: url).tap do |bridge|
313
+ bridge.create_session(caps)
314
+ end
315
+ end
316
+
317
+ def process_options(options, capabilities)
318
+ if options && capabilities
319
+ msg = "Don't use both :options and :capabilities when initializing #{self.class}, prefer :options"
320
+ raise ArgumentError, msg
321
+ end
322
+
323
+ options ? options.as_json : deprecate_capabilities(capabilities)
324
+ end
325
+
326
+ def deprecate_capabilities(capabilities)
327
+ unless is_a?(Remote::Driver)
328
+ WebDriver.logger.deprecate("The :capabilities parameter for #{self.class}",
329
+ ":options argument with an instance of #{self.class}",
330
+ id: :capabilities)
324
331
  end
332
+ generate_capabilities(capabilities)
325
333
  end
326
334
 
327
335
  def generate_capabilities(capabilities)
328
336
  Array(capabilities).map { |cap|
329
337
  if cap.is_a? Symbol
330
- cap = Remote::Capabilities.send(cap)
338
+ cap = WebDriver::Options.send(cap)
331
339
  elsif !cap.respond_to? :as_json
332
340
  msg = ":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not"
333
341
  raise ArgumentError, msg
334
342
  end
335
343
  cap.as_json
336
- }.inject(:merge) || Remote::Capabilities.send(browser || :new)
344
+ }.inject(:merge)
337
345
  end
338
346
 
339
347
  def service_url(service)
340
- service ||= Service.send(browser)
341
- @service = service.launch
342
- @service.uri
348
+ @service_manager = service.launch
349
+ @service_manager.uri
343
350
  end
344
351
 
345
352
  def screenshot
@@ -349,11 +356,13 @@ module Selenium
349
356
  def add_extensions(browser)
350
357
  extensions = case browser
351
358
  when :chrome, :msedge
352
- Chrome::Driver::EXTENSIONS
359
+ Chromium::Driver::EXTENSIONS
353
360
  when :firefox
354
361
  Firefox::Driver::EXTENSIONS
355
362
  when :safari, :safari_technology_preview
356
363
  Safari::Driver::EXTENSIONS
364
+ when :ie, :internet_explorer
365
+ IE::Driver::EXTENSIONS
357
366
  else
358
367
  []
359
368
  end
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module DownloadsFiles
24
-
25
24
  #
26
25
  # Sets download path for Chromium.
27
26
  #
@@ -38,7 +37,6 @@ module Selenium
38
37
  }
39
38
  @bridge.send_command(params)
40
39
  end
41
-
42
40
  end # DownloadsFiles
43
41
  end # DriverExtensions
44
42
  end # WebDriver
@@ -36,7 +36,6 @@ module Selenium
36
36
  def full_screenshot
37
37
  @bridge.full_screenshot
38
38
  end
39
-
40
39
  end # FullPageScreenshot
41
40
  end # DriverExtensions
42
41
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasAddons
24
-
25
24
  #
26
25
  # Installs addon.
27
26
  #
@@ -43,7 +42,6 @@ module Selenium
43
42
  def uninstall_addon(id)
44
43
  @bridge.uninstall_addon(id)
45
44
  end
46
-
47
45
  end # HasAddons
48
46
  end # DriverExtensions
49
47
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasApplePermissions
24
-
25
24
  #
26
25
  # Returns permissions.
27
26
  #
@@ -44,7 +43,6 @@ module Selenium
44
43
  def permissions=(permissions)
45
44
  @bridge.permissions = permissions
46
45
  end
47
-
48
46
  end # HasPermissions
49
47
  end # DriverExtensions
50
48
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasAuthentication
24
-
25
24
  #
26
25
  # Registers basic authentication handler which is automatically
27
26
  # used whenever browser gets an authentication required response.
@@ -82,7 +81,6 @@ module Selenium
82
81
  )
83
82
  end
84
83
  end
85
-
86
84
  end # HasAuthentication
87
85
  end # DriverExtensions
88
86
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasBiDi
24
-
25
24
  #
26
25
  # Retrieves WebDriver BiDi connection.
27
26
  #
@@ -31,7 +30,6 @@ module Selenium
31
30
  def bidi
32
31
  @bidi ||= Selenium::WebDriver::BiDi.new(url: capabilities[:web_socket_url])
33
32
  end
34
-
35
33
  end # HasBiDi
36
34
  end # DriverExtensions
37
35
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasCasting
24
-
25
24
  #
26
25
  # What devices ("sinks") are available to be cast to.
27
26
  #
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasCDP
24
-
25
24
  #
26
25
  # Returns network conditions.
27
26
  #
@@ -31,7 +30,6 @@ module Selenium
31
30
  def execute_cdp(cmd, **params)
32
31
  @bridge.send_command(cmd: cmd, params: params)
33
32
  end
34
-
35
33
  end # HasCDP
36
34
  end # DriverExtensions
37
35
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasContext
24
-
25
24
  #
26
25
  # Sets the context that Selenium commands are running in using
27
26
  # a `with` statement. The state of the context on the server is
@@ -37,7 +36,6 @@ module Selenium
37
36
  def context
38
37
  @bridge.context
39
38
  end
40
-
41
39
  end # HasContext
42
40
  end # DriverExtensions
43
41
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasDebugger
24
-
25
24
  #
26
25
  # Attaches debugger to session.
27
26
  #
@@ -35,7 +34,6 @@ module Selenium
35
34
  def attach_debugger
36
35
  @bridge.attach_debugger
37
36
  end
38
-
39
37
  end # HasDebugger
40
38
  end # DriverExtensions
41
39
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasDevTools
24
-
25
24
  #
26
25
  # Retrieves connection to DevTools.
27
26
  #
@@ -36,7 +35,6 @@ module Selenium
36
35
  Selenium::WebDriver::DevTools.new(url: devtools_url)
37
36
  end
38
37
  end
39
-
40
38
  end # HasDevTools
41
39
  end # DriverExtensions
42
40
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasLaunching
24
-
25
24
  #
26
25
  # Launches Chromium app specified by id.
27
26
  #
@@ -31,7 +30,6 @@ module Selenium
31
30
  def launch_app(id)
32
31
  @bridge.launch_app(id)
33
32
  end
34
-
35
33
  end # HasLaunching
36
34
  end # DriverExtensions
37
35
  end # WebDriver
@@ -29,8 +29,7 @@ module Selenium
29
29
  def location=(*)
30
30
  raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
31
31
  end
32
- alias_method :set_location, :location
33
-
32
+ alias set_location location
34
33
  end # HasLocation
35
34
  end # DriverExtensions
36
35
  end # WebDriver
@@ -137,7 +137,6 @@ module Selenium
137
137
  def mutation_listener
138
138
  @mutation_listener ||= read_atom(:mutationListener)
139
139
  end
140
-
141
140
  end # HasLogEvents
142
141
  end # DriverExtensions
143
142
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasNetworkConditions
24
-
25
24
  #
26
25
  # Returns network conditions.
27
26
  #
@@ -61,7 +60,6 @@ module Selenium
61
60
  def delete_network_conditions
62
61
  @bridge.delete_network_conditions
63
62
  end
64
-
65
63
  end # HasNetworkConditions
66
64
  end # DriverExtensions
67
65
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasNetworkInterception
24
-
25
24
  #
26
25
  # Intercepts requests coming from browser allowing
27
26
  # to either pass them through like proxy or provide
@@ -64,7 +63,6 @@ module Selenium
64
63
  @interceptor ||= DevTools::NetworkInterceptor.new(devtools)
65
64
  @interceptor.intercept(&block)
66
65
  end
67
-
68
66
  end # HasNetworkInterception
69
67
  end # DriverExtensions
70
68
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasPermissions
24
-
25
24
  #
26
25
  # Set one permission.
27
26
  #
@@ -44,7 +43,6 @@ module Selenium
44
43
  @bridge.set_permission(key, value)
45
44
  end
46
45
  end
47
-
48
46
  end # HasPermissions
49
47
  end # DriverExtensions
50
48
  end # WebDriver
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasPinnedScripts
24
-
25
24
  #
26
25
  # Returns the list of all pinned scripts.
27
26
  #
@@ -70,7 +69,6 @@ module Selenium
70
69
  devtools.page.remove_script_to_evaluate_on_new_document(identifier: script.devtools_identifier)
71
70
  pinned_scripts.delete(script)
72
71
  end
73
-
74
72
  end # HasPinnedScripts
75
73
  end # DriverExtensions
76
74
  end # WebDriver
@@ -43,7 +43,7 @@ module Selenium
43
43
  def ==(other)
44
44
  other.is_a?(self.class) && ref == other.ref
45
45
  end
46
- alias_method :eql?, :==
46
+ alias eql? ==
47
47
 
48
48
  def hash
49
49
  [@id, @bridge].hash
@@ -207,7 +207,7 @@ module Selenium
207
207
  def send_keys(*args)
208
208
  bridge.send_keys_to_element @id, Keys.encode(args)
209
209
  end
210
- alias_method :send_key, :send_keys
210
+ alias send_key send_keys
211
211
 
212
212
  #
213
213
  # If this element is a text entry element, this will clear the value. Has no effect on other
@@ -275,7 +275,7 @@ module Selenium
275
275
  def css_value(prop)
276
276
  bridge.element_value_of_css_property @id, prop
277
277
  end
278
- alias_method :style, :css_value
278
+ alias style css_value
279
279
 
280
280
  #
281
281
  # Get the location of this element.
@@ -333,18 +333,18 @@ module Selenium
333
333
  # element.first(id: 'foo')
334
334
  #
335
335
 
336
- alias_method :first, :find_element
336
+ alias first find_element
337
337
 
338
338
  #
339
339
  # element.all(class: 'bar')
340
340
  #
341
341
 
342
- alias_method :all, :find_elements
342
+ alias all find_elements
343
343
 
344
344
  #
345
345
  # element['class'] or element[:class] #=> "someclass"
346
346
  #
347
- alias_method :[], :attribute
347
+ alias [] attribute
348
348
 
349
349
  #
350
350
  # @api private
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Error
23
-
24
23
  #
25
24
  # Returns exception from its string representation.
26
25
  # @param [String, nil] error
@@ -213,7 +212,6 @@ module Selenium
213
212
  #
214
213
 
215
214
  class UnsupportedOperationError < WebDriverError; end
216
-
217
215
  end # Error
218
216
  end # WebDriver
219
217
  end # Selenium
@@ -26,8 +26,8 @@ module Selenium
26
26
  def key?(key)
27
27
  keys.include? key
28
28
  end
29
- alias_method :member?, :key?
30
- alias_method :has_key?, :key?
29
+ alias member? key?
30
+ alias has_key? key?
31
31
 
32
32
  def fetch(key)
33
33
  return self[key] if key? key
@@ -95,9 +95,9 @@ module Selenium
95
95
  # @return [ActionBuilder] A self reference.
96
96
  #
97
97
 
98
- def move_to(element, right_by = nil, down_by = nil, device: nil, duration: default_move_duration, **opts)
99
- pointer = pointer_input(device)
100
- pointer.create_pointer_move(duration: duration,
98
+ def move_to(element, right_by = nil, down_by = nil, **opts)
99
+ pointer = pointer_input(opts.delete(:device))
100
+ pointer.create_pointer_move(duration: opts.delete(:duration) || default_move_duration,
101
101
  x: right_by || 0,
102
102
  y: down_by || 0,
103
103
  origin: element,
@@ -33,12 +33,12 @@ module Selenium
33
33
  POINTER = :pointer
34
34
  ORIGINS = [VIEWPORT, POINTER].freeze
35
35
 
36
- def initialize(source, duration, x, y, element: nil, origin: nil, **opts)
36
+ def initialize(source, duration, x, y, **opts)
37
37
  super(source)
38
38
  @duration = duration * 1000
39
39
  @x_offset = x
40
40
  @y_offset = y
41
- @origin = element || origin || :viewport
41
+ @origin = opts.delete(:element) || opts.delete(:origin) || :viewport
42
42
  @type = :pointerMove
43
43
  @opts = opts
44
44
  end
@@ -27,15 +27,17 @@ module Selenium
27
27
  #
28
28
 
29
29
  class Scroll < Interaction
30
- def initialize(source:, x: 0, y: 0, delta_x: 0, delta_y: 0, origin: :viewport, duration: 0.25)
30
+ def initialize(source:, origin: :viewport, duration: 0.25, **opts)
31
31
  super(source)
32
32
  @type = :scroll
33
33
  @duration = duration * 1000
34
34
  @origin = origin
35
- @x_offset = x
36
- @y_offset = y
37
- @delta_x = delta_x
38
- @delta_y = delta_y
35
+ @x_offset = opts.delete(:x) || 0
36
+ @y_offset = opts.delete(:y) || 0
37
+ @delta_x = opts.delete(:delta_x) || 0
38
+ @delta_y = opts.delete(:delta_y) || 0
39
+
40
+ raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
39
41
  end
40
42
 
41
43
  def assert_source(source)
@@ -48,9 +48,10 @@ module Selenium
48
48
  #
49
49
  # @param [String] progname Allow child projects to use Selenium's Logger pattern
50
50
  #
51
- def initialize(progname = 'Selenium')
51
+ def initialize(progname = 'Selenium', ignored: nil)
52
52
  @logger = create_logger(progname)
53
- @ignored = []
53
+ @ignored = Array(ignored)
54
+ @first_warning = false
54
55
  end
55
56
 
56
57
  #
@@ -94,6 +95,13 @@ module Selenium
94
95
  # @yield see #deprecate
95
96
  #
96
97
  def warn(message, id: [])
98
+ unless @first_warning
99
+ @first_warning = true
100
+ warn("Details on how to use and modify Selenium logger:\n", id: [:logger_info]) do
101
+ "https://selenium.dev/documentation/webdriver/troubleshooting/logging#ruby\n"
102
+ end
103
+ end
104
+
97
105
  id = Array(id)
98
106
  return if (@ignored & id).any?
99
107
 
@@ -38,12 +38,12 @@ module Selenium
38
38
  def ie(**opts)
39
39
  IE::Options.new(**opts)
40
40
  end
41
- alias_method :internet_explorer, :ie
41
+ alias internet_explorer ie
42
42
 
43
43
  def edge(**opts)
44
44
  Edge::Options.new(**opts)
45
45
  end
46
- alias_method :microsoftedge, :edge
46
+ alias microsoftedge edge
47
47
 
48
48
  def safari(**opts)
49
49
  Safari::Options.new(**opts)
@@ -85,7 +85,13 @@ module Selenium
85
85
  #
86
86
 
87
87
  def add_option(name, value = nil)
88
- @options[name.keys.first] = name.values.first if value.nil? && name.is_a?(Hash)
88
+ name, value = name.first if value.nil? && name.is_a?(Hash)
89
+
90
+ unless name.to_s.include?(':')
91
+ WebDriver.logger.deprecate('Options#add_option for w3c or browser specific capabilities',
92
+ 'applicable attribute accessors or pass into constructor',
93
+ id: :add_option)
94
+ end
89
95
  @options[name] = value
90
96
  end
91
97
 
@@ -95,7 +101,7 @@ module Selenium
95
101
  as_json == other.as_json
96
102
  end
97
103
 
98
- alias_method :eql?, :==
104
+ alias eql? ==
99
105
 
100
106
  #
101
107
  # @api private
@@ -106,11 +112,27 @@ module Selenium
106
112
 
107
113
  w3c_options = process_w3c_options(options)
108
114
 
109
- self.class::CAPABILITIES.each do |capability_alias, capability_name|
110
- capability_value = options.delete(capability_alias)
111
- options[capability_name] = capability_value if !capability_value.nil? && !options.key?(capability_name)
115
+ browser_options = self.class::CAPABILITIES.each_with_object({}) do |(capability_alias, capability_name), hash|
116
+ from_name = options.delete(capability_name)
117
+ from_alias = options.delete(capability_alias)
118
+ capability_value = if !from_name.nil? && capability_alias != capability_name
119
+ WebDriver.logger.deprecate("#{capability_name} as option",
120
+ capability_alias.to_s, id: :option_symbols)
121
+ from_name
122
+ elsif !from_alias.nil?
123
+ from_alias
124
+ end
125
+
126
+ hash[capability_name] = capability_value unless capability_value.nil?
112
127
  end
113
- browser_options = defined?(self.class::KEY) ? {self.class::KEY => options} : options
128
+
129
+ unless options.empty?
130
+ msg = 'These options are not w3c compliant and will result in failures in a future release'
131
+ WebDriver.logger.warn("#{msg}: #{options}")
132
+ browser_options.merge!(options)
133
+ end
134
+
135
+ browser_options = {self.class::KEY => browser_options} if defined?(self.class::KEY)
114
136
 
115
137
  process_browser_options(browser_options)
116
138
  generate_as_json(w3c_options.merge(browser_options))
@@ -40,7 +40,7 @@ module Selenium
40
40
  end
41
41
 
42
42
  def as_json(*)
43
- {"zip" => encoded}
43
+ {'zip' => encoded}
44
44
  end
45
45
 
46
46
  def to_json(*)
@@ -74,7 +74,7 @@ module Selenium
74
74
  def ==(other)
75
75
  other.is_a?(self.class) && as_json == other.as_json
76
76
  end
77
- alias_method :eql?, :==
77
+ alias eql? ==
78
78
 
79
79
  def ftp=(value)
80
80
  self.type = :manual