selenium-webdriver 4.1.0 → 4.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +405 -1
  3. data/Gemfile +3 -0
  4. data/LICENSE +1 -1
  5. data/NOTICE +1 -1
  6. data/README.md +3 -3
  7. data/bin/linux/selenium-manager +0 -0
  8. data/bin/macos/selenium-manager +0 -0
  9. data/bin/windows/selenium-manager.exe +0 -0
  10. data/lib/selenium/server.rb +38 -40
  11. data/lib/selenium/webdriver/atoms/findElements.js +27 -27
  12. data/lib/selenium/webdriver/atoms/getAttribute.js +6 -100
  13. data/lib/selenium/webdriver/atoms/isDisplayed.js +24 -96
  14. data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
  15. data/lib/selenium/webdriver/atoms.rb +5 -3
  16. data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
  17. data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
  18. data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
  19. data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
  20. data/lib/selenium/webdriver/{common/driver_extensions/has_location.rb → bidi/log/filter_by.rb} +14 -11
  21. data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
  22. data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
  23. data/lib/selenium/webdriver/bidi/log_handler.rb +63 -0
  24. data/lib/selenium/webdriver/bidi/log_inspector.rb +147 -0
  25. data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
  26. data/lib/selenium/webdriver/bidi/session.rb +51 -0
  27. data/lib/selenium/webdriver/bidi/struct.rb +44 -0
  28. data/lib/selenium/webdriver/bidi.rb +66 -0
  29. data/lib/selenium/webdriver/chrome/driver.rb +9 -29
  30. data/lib/selenium/webdriver/chrome/features.rb +9 -67
  31. data/lib/selenium/webdriver/chrome/options.rb +3 -223
  32. data/lib/selenium/webdriver/chrome/profile.rb +3 -83
  33. data/lib/selenium/webdriver/chrome/service.rb +4 -19
  34. data/lib/selenium/webdriver/chrome.rb +0 -16
  35. data/lib/selenium/webdriver/chromium/driver.rb +61 -0
  36. data/lib/selenium/webdriver/chromium/features.rb +99 -0
  37. data/lib/selenium/webdriver/chromium/options.rb +243 -0
  38. data/lib/selenium/webdriver/chromium/profile.rb +113 -0
  39. data/lib/selenium/webdriver/chromium.rb +29 -0
  40. data/lib/selenium/webdriver/common/action_builder.rb +60 -22
  41. data/lib/selenium/webdriver/common/child_process.rb +130 -0
  42. data/lib/selenium/webdriver/common/driver.rb +46 -90
  43. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
  44. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
  45. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
  46. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
  47. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
  48. data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_bidi.rb} +10 -5
  49. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +10 -1
  50. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
  51. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +1 -4
  52. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
  53. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
  54. data/lib/selenium/webdriver/common/driver_extensions/has_fedcm_dialog.rb +55 -0
  55. data/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb +65 -0
  56. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
  57. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +2 -3
  58. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
  59. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +2 -69
  60. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
  61. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +1 -3
  62. data/lib/selenium/webdriver/common/driver_finder.rb +97 -0
  63. data/lib/selenium/webdriver/common/element.rb +8 -8
  64. data/lib/selenium/webdriver/common/error.rb +27 -4
  65. data/lib/selenium/webdriver/common/fedcm/account.rb +50 -0
  66. data/lib/selenium/webdriver/common/fedcm/dialog.rb +74 -0
  67. data/lib/selenium/webdriver/common/fedcm.rb +27 -0
  68. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
  69. data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
  70. data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -25
  71. data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
  72. data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -1
  73. data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
  74. data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
  75. data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
  76. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +59 -71
  77. data/lib/selenium/webdriver/common/{driver_extensions/has_network_connection.rb → interactions/pointer_cancel.rb} +19 -11
  78. data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
  79. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
  80. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
  81. data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
  82. data/lib/selenium/webdriver/common/interactions/scroll.rb +59 -0
  83. data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
  84. data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
  85. data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +114 -0
  86. data/lib/selenium/webdriver/common/interactions/wheel_input.rb +42 -0
  87. data/lib/selenium/webdriver/common/keys.rb +1 -0
  88. data/lib/selenium/webdriver/common/local_driver.rb +53 -0
  89. data/lib/selenium/webdriver/common/logger.rb +93 -28
  90. data/lib/selenium/webdriver/common/manager.rb +1 -28
  91. data/lib/selenium/webdriver/common/options.rb +19 -19
  92. data/lib/selenium/webdriver/common/platform.rb +12 -52
  93. data/lib/selenium/webdriver/common/port_prober.rb +1 -1
  94. data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
  95. data/lib/selenium/webdriver/common/proxy.rb +4 -4
  96. data/lib/selenium/webdriver/common/script.rb +45 -0
  97. data/lib/selenium/webdriver/common/search_context.rb +10 -8
  98. data/lib/selenium/webdriver/common/selenium_manager.rb +104 -0
  99. data/lib/selenium/webdriver/common/service.rb +21 -30
  100. data/lib/selenium/webdriver/common/service_manager.rb +8 -15
  101. data/lib/selenium/webdriver/common/shadow_root.rb +2 -3
  102. data/lib/selenium/webdriver/common/socket_lock.rb +3 -3
  103. data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
  104. data/lib/selenium/webdriver/common/takes_screenshot.rb +6 -5
  105. data/lib/selenium/webdriver/common/target_locator.rb +2 -3
  106. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  107. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
  108. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
  109. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
  110. data/lib/selenium/webdriver/common/websocket_connection.rb +176 -0
  111. data/lib/selenium/webdriver/common/window.rb +6 -6
  112. data/lib/selenium/webdriver/common/zipper.rb +1 -1
  113. data/lib/selenium/webdriver/common.rb +26 -5
  114. data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
  115. data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
  116. data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
  117. data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
  118. data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
  119. data/lib/selenium/webdriver/devtools/request.rb +1 -3
  120. data/lib/selenium/webdriver/devtools/response.rb +1 -3
  121. data/lib/selenium/webdriver/devtools.rb +17 -114
  122. data/lib/selenium/webdriver/edge/driver.rb +9 -3
  123. data/lib/selenium/webdriver/edge/features.rb +8 -4
  124. data/lib/selenium/webdriver/edge/options.rb +17 -5
  125. data/lib/selenium/webdriver/edge/profile.rb +2 -2
  126. data/lib/selenium/webdriver/edge/service.rb +8 -7
  127. data/lib/selenium/webdriver/edge.rb +0 -2
  128. data/lib/selenium/webdriver/firefox/driver.rb +9 -2
  129. data/lib/selenium/webdriver/firefox/features.rb +11 -7
  130. data/lib/selenium/webdriver/firefox/options.rb +10 -16
  131. data/lib/selenium/webdriver/firefox/profile.rb +21 -17
  132. data/lib/selenium/webdriver/firefox/profiles_ini.rb +1 -1
  133. data/lib/selenium/webdriver/firefox/service.rb +0 -18
  134. data/lib/selenium/webdriver/firefox/util.rb +46 -0
  135. data/lib/selenium/webdriver/firefox.rb +1 -14
  136. data/lib/selenium/webdriver/ie/driver.rb +7 -1
  137. data/lib/selenium/webdriver/ie/features.rb +34 -0
  138. data/lib/selenium/webdriver/ie/options.rb +6 -4
  139. data/lib/selenium/webdriver/ie/service.rb +0 -22
  140. data/lib/selenium/webdriver/ie.rb +4 -17
  141. data/lib/selenium/webdriver/remote/bidi_bridge.rb +44 -0
  142. data/lib/selenium/webdriver/remote/{commands.rb → bridge/commands.rb} +22 -9
  143. data/lib/selenium/webdriver/remote/bridge/locator_converter.rb +76 -0
  144. data/lib/selenium/webdriver/remote/bridge.rb +147 -99
  145. data/lib/selenium/webdriver/remote/capabilities.rb +5 -55
  146. data/lib/selenium/webdriver/remote/driver.rb +35 -14
  147. data/lib/selenium/webdriver/remote/features.rb +75 -0
  148. data/lib/selenium/webdriver/remote/http/common.rb +24 -6
  149. data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
  150. data/lib/selenium/webdriver/remote/http/default.rb +8 -14
  151. data/lib/selenium/webdriver/remote/response.rb +8 -34
  152. data/lib/selenium/webdriver/remote/server_error.rb +2 -2
  153. data/lib/selenium/webdriver/remote.rb +2 -1
  154. data/lib/selenium/webdriver/safari/driver.rb +7 -1
  155. data/lib/selenium/webdriver/safari/features.rb +5 -3
  156. data/lib/selenium/webdriver/safari/options.rb +5 -1
  157. data/lib/selenium/webdriver/safari/service.rb +10 -4
  158. data/lib/selenium/webdriver/safari.rb +1 -15
  159. data/lib/selenium/webdriver/support/color.rb +22 -22
  160. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  161. data/lib/selenium/webdriver/support/guards/guard.rb +14 -14
  162. data/lib/selenium/webdriver/support/guards/guard_condition.rb +1 -3
  163. data/lib/selenium/webdriver/support/guards.rb +2 -2
  164. data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
  165. data/lib/selenium/webdriver/support/select.rb +3 -1
  166. data/lib/selenium/webdriver/version.rb +1 -1
  167. data/lib/selenium/webdriver.rb +7 -5
  168. data/selenium-webdriver.gemspec +20 -16
  169. metadata +135 -47
  170. data/lib/selenium/webdriver/remote/http/persistent.rb +0 -65
  171. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
  172. data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -43,7 +43,7 @@ module Selenium
43
43
 
44
44
  def for(browser, opts = {})
45
45
  case browser
46
- when :chrome
46
+ when :chrome, :chrome_headless_shell
47
47
  Chrome::Driver.new(**opts)
48
48
  when :internet_explorer, :ie
49
49
  IE::Driver.new(**opts)
@@ -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,11 +69,10 @@ module Selenium
69
69
  #
70
70
 
71
71
  def initialize(bridge: nil, listener: nil, **opts)
72
- @service = nil
73
72
  @devtools = nil
74
73
  bridge ||= create_bridge(**opts)
75
- add_extensions(bridge.browser)
76
74
  @bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
75
+ add_extensions(@bridge.browser)
77
76
  end
78
77
 
79
78
  def inspect
@@ -100,6 +99,22 @@ module Selenium
100
99
  @navigate ||= WebDriver::Navigation.new(bridge)
101
100
  end
102
101
 
102
+ #
103
+ # @return [Script]
104
+ # @see Script
105
+ #
106
+
107
+ def script(*args)
108
+ if args.any?
109
+ WebDriver.logger.deprecate('`Driver#script` as an alias for `#execute_script`',
110
+ '`Driver#execute_script`',
111
+ id: :driver_script)
112
+ execute_script(*args)
113
+ else
114
+ @script ||= WebDriver::Script.new(bridge)
115
+ end
116
+ end
117
+
103
118
  #
104
119
  # @return [TargetLocator]
105
120
  # @see TargetLocator
@@ -123,16 +138,8 @@ module Selenium
123
138
  # @see ActionBuilder
124
139
  #
125
140
 
126
- def action
127
- bridge.action
128
- end
129
-
130
- def mouse
131
- bridge.mouse
132
- end
133
-
134
- def keyboard
135
- bridge.keyboard
141
+ def action(**opts)
142
+ bridge.action(**opts)
136
143
  end
137
144
 
138
145
  #
@@ -180,7 +187,7 @@ module Selenium
180
187
  def quit
181
188
  bridge.quit
182
189
  ensure
183
- @service&.stop
190
+ @service_manager&.stop
184
191
  @devtools&.close
185
192
  end
186
193
 
@@ -189,7 +196,7 @@ module Selenium
189
196
  #
190
197
 
191
198
  def close
192
- bridge.close
199
+ bridge&.close
193
200
  end
194
201
 
195
202
  #
@@ -248,25 +255,28 @@ module Selenium
248
255
  bridge.execute_async_script(script, *args)
249
256
  end
250
257
 
251
- #-------------------------------- sugar --------------------------------
252
-
253
258
  #
254
- # driver.first(id: 'foo')
259
+ # @return [VirtualAuthenticator]
260
+ # @see VirtualAuthenticator
255
261
  #
256
262
 
257
- alias_method :first, :find_element
263
+ def add_virtual_authenticator(options)
264
+ bridge.add_virtual_authenticator(options)
265
+ end
266
+
267
+ #-------------------------------- sugar --------------------------------
258
268
 
259
269
  #
260
- # driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
270
+ # driver.first(id: 'foo')
261
271
  #
262
272
 
263
- alias_method :all, :find_elements
273
+ alias first find_element
264
274
 
265
275
  #
266
- # driver.script('function() { ... };')
276
+ # driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
267
277
  #
268
278
 
269
- alias_method :script, :execute_script
279
+ alias all find_elements
270
280
 
271
281
  # Get the first element matching the given selector. If given a
272
282
  # String or Symbol, it will be used as the id of the element.
@@ -287,7 +297,7 @@ module Selenium
287
297
  end
288
298
 
289
299
  def browser
290
- bridge&.browser
300
+ bridge.browser
291
301
  end
292
302
 
293
303
  def capabilities
@@ -307,72 +317,16 @@ module Selenium
307
317
 
308
318
  attr_reader :bridge
309
319
 
310
- def create_bridge(**opts)
311
- opts[:url] ||= service_url(opts)
312
- caps = opts.delete(:capabilities)
313
- # NOTE: This is deprecated
314
- cap_array = caps.is_a?(Hash) ? [caps] : Array(caps)
315
-
316
- desired_capabilities = opts.delete(:desired_capabilities)
317
- if desired_capabilities
318
- WebDriver.logger.deprecate(':desired_capabilities as a parameter for driver initialization',
319
- ':capabilities with an Array value of capabilities/options if necessary',
320
- id: :desired_capabilities)
321
- desired_capabilities = Remote::Capabilities.new(desired_capabilities) if desired_capabilities.is_a?(Hash)
322
- cap_array << desired_capabilities
320
+ def create_bridge(caps:, url:, http_client: nil)
321
+ klass = caps['webSocketUrl'] ? Remote::BiDiBridge : Remote::Bridge
322
+ klass.new(http_client: http_client, url: url).tap do |bridge|
323
+ bridge.create_session(caps)
323
324
  end
324
-
325
- options = opts.delete(:options)
326
- if options
327
- WebDriver.logger.deprecate(':options as a parameter for driver initialization',
328
- ':capabilities with an Array of value capabilities/options if necessary',
329
- id: :browser_options)
330
- cap_array << options
331
- end
332
-
333
- capabilities = generate_capabilities(cap_array)
334
-
335
- bridge_opts = {http_client: opts.delete(:http_client), url: opts.delete(:url)}
336
- raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
337
-
338
- bridge = Remote::Bridge.new(**bridge_opts)
339
-
340
- bridge.create_session(capabilities)
341
- bridge
342
325
  end
343
326
 
344
- def generate_capabilities(cap_array)
345
- cap_array.map { |cap|
346
- if cap.is_a? Symbol
347
- cap = Remote::Capabilities.send(cap)
348
- elsif cap.is_a? Hash
349
- new_message = 'Capabilities instance initialized with the Hash, or build values with Options class'
350
- WebDriver.logger.deprecate("passing a Hash value to :capabilities",
351
- new_message,
352
- id: :capabilities_hash)
353
- cap = Remote::Capabilities.new(cap)
354
- elsif !cap.respond_to? :as_json
355
- msg = ":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not"
356
- raise ArgumentError, msg
357
- end
358
- cap&.as_json
359
- }.inject(:merge) || Remote::Capabilities.send(browser || :new)
360
- end
361
-
362
- def service_url(opts)
363
- service_config = opts.delete(:service)
364
- %i[driver_opts driver_path port].each do |key|
365
- next unless opts.key? key
366
-
367
- WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service',
368
- id: "service_#{key}".to_sym)
369
- end
370
- service_config ||= Service.send(browser,
371
- args: opts.delete(:driver_opts),
372
- path: opts.delete(:driver_path),
373
- port: opts.delete(:port))
374
- @service = service_config.launch
375
- @service.uri
327
+ def service_url(service)
328
+ @service_manager = service.launch
329
+ @service_manager.uri
376
330
  end
377
331
 
378
332
  def screenshot
@@ -381,12 +335,14 @@ module Selenium
381
335
 
382
336
  def add_extensions(browser)
383
337
  extensions = case browser
384
- when :chrome, :msedge
385
- Chrome::Driver::EXTENSIONS
338
+ when :chrome, :chrome_headless_shell, :msedge, :microsoftedge
339
+ Chromium::Driver::EXTENSIONS
386
340
  when :firefox
387
341
  Firefox::Driver::EXTENSIONS
388
342
  when :safari, :safari_technology_preview
389
343
  Safari::Driver::EXTENSIONS
344
+ when :ie, :internet_explorer
345
+ IE::Driver::EXTENSIONS
390
346
  else
391
347
  []
392
348
  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
@@ -20,12 +20,17 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
- module HasRemoteStatus
24
- def remote_status
25
- WebDriver.logger.deprecate('#remote_status', '#status')
26
- @bridge.status
23
+ module HasBiDi
24
+ #
25
+ # Retrieves WebDriver BiDi connection.
26
+ #
27
+ # @return [BiDi]
28
+ #
29
+
30
+ def bidi
31
+ @bridge.bidi
27
32
  end
28
- end # HasRemoteStatus
33
+ end # HasBiDi
29
34
  end # DriverExtensions
30
35
  end # WebDriver
31
36
  end # Selenium
@@ -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
  #
@@ -52,6 +51,16 @@ module Selenium
52
51
  @bridge.start_cast_tab_mirroring(name)
53
52
  end
54
53
 
54
+ #
55
+ # Starts a tab mirroring session on a specific receiver target.
56
+ #
57
+ # @param [String] name the sink to use as the target
58
+ #
59
+
60
+ def start_cast_desktop_mirroring(name)
61
+ @bridge.start_cast_desktop_mirroring(name)
62
+ end
63
+
55
64
  #
56
65
  # Gets error messages when there is any issue in a Cast session.
57
66
  #
@@ -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,14 +21,12 @@ 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
28
27
  # saved before entering the block, and restored upon exiting it.
29
28
  #
30
- # @param [String] name which permission to set
31
- # @param [String] value what to set the permission to
29
+ # @param [String] value which context gets set (either 'chrome' or 'content')
32
30
  #
33
31
 
34
32
  def context=(value)
@@ -38,7 +36,6 @@ module Selenium
38
36
  def context
39
37
  @bridge.context
40
38
  end
41
-
42
39
  end # HasContext
43
40
  end # DriverExtensions
44
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
@@ -0,0 +1,55 @@
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 DriverExtensions
23
+ module HasFedCmDialog
24
+ # Disables the promise rejection delay for FedCm.
25
+ #
26
+ # FedCm by default delays promise resolution in failure cases for privacy reasons.
27
+ # This method allows turning it off to let tests run faster where this is not relevant.
28
+ def enable_fedcm_delay=(enable)
29
+ @bridge.fedcm_delay(enable)
30
+ end
31
+
32
+ # Resets the FedCm dialog cooldown.
33
+ #
34
+ # If a user agent triggers a cooldown when the account chooser is dismissed,
35
+ # this method resets that cooldown so that the dialog can be triggered again immediately.
36
+ def reset_fedcm_cooldown
37
+ @bridge.reset_fedcm_cooldown
38
+ end
39
+
40
+ def fedcm_dialog
41
+ @fedcm_dialog ||= FedCM::Dialog.new(@bridge)
42
+ end
43
+
44
+ def wait_for_fedcm_dialog(timeout: 5, interval: 0.2, message: nil, ignore: nil)
45
+ wait = Wait.new(timeout: timeout, interval: interval, message: message, ignore: ignore)
46
+ wait.until do
47
+ fedcm_dialog if fedcm_dialog.type
48
+ rescue Error::NoSuchAlertError
49
+ nil
50
+ end
51
+ end
52
+ end # HasFedCmDialog
53
+ end # DriverExtensions
54
+ end # WebDriver
55
+ end # Selenium
@@ -0,0 +1,65 @@
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 DriverExtensions
23
+ module HasFileDownloads
24
+ def downloadable_files
25
+ verify_enabled
26
+
27
+ @bridge.downloadable_files['names']
28
+ end
29
+
30
+ def download_file(file_name, target_directory)
31
+ verify_enabled
32
+
33
+ response = @bridge.download_file(file_name)
34
+ contents = response['contents']
35
+
36
+ File.open("#{file_name}.zip", 'wb') { |f| f << Base64.decode64(contents) }
37
+ target_directory += '/' unless target_directory.end_with?('/')
38
+ FileUtils.mkdir_p(target_directory)
39
+
40
+ begin
41
+ Zip::File.open("#{file_name}.zip") do |zip|
42
+ zip.each { |entry| zip.extract(entry, "#{target_directory}#{file_name}") }
43
+ end
44
+ ensure
45
+ FileUtils.rm_f("#{file_name}.zip")
46
+ end
47
+ end
48
+
49
+ def delete_downloadable_files
50
+ verify_enabled
51
+
52
+ @bridge.delete_downloadable_files
53
+ end
54
+
55
+ private
56
+
57
+ def verify_enabled
58
+ return if capabilities['se:downloadsEnabled']
59
+
60
+ raise Error::WebDriverError, 'You must enable downloads in order to work with downloadable files.'
61
+ end
62
+ end # HasFileDownloads
63
+ end # DriverExtensions
64
+ end # WebDriver
65
+ end # Selenium
@@ -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
@@ -64,7 +64,7 @@ module Selenium
64
64
  return if enabled
65
65
 
66
66
  devtools.runtime.enable
67
- __send__("log_#{kind}_events")
67
+ __send__(:"log_#{kind}_events")
68
68
  end
69
69
 
70
70
  private
@@ -114,7 +114,7 @@ module Selenium
114
114
  execute_script(mutation_listener)
115
115
  devtools.page.add_script_to_evaluate_on_new_document(source: mutation_listener)
116
116
 
117
- devtools.runtime.on(:binding_called, &method(:log_mutation_event))
117
+ devtools.runtime.on(:binding_called) { |event| log_mutation_event(event) }
118
118
  end
119
119
 
120
120
  def log_mutation_event(params)
@@ -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