selenium-webdriver 4.0.0.alpha2 → 4.0.0

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 (113) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +338 -4
  3. data/Gemfile +3 -1
  4. data/LICENSE +1 -1
  5. data/NOTICE +2 -0
  6. data/README.md +4 -5
  7. data/lib/selenium/server.rb +21 -29
  8. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  9. data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
  10. data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
  11. data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
  12. data/lib/selenium/webdriver/chrome/driver.rb +26 -56
  13. data/lib/selenium/webdriver/chrome/features.rb +106 -0
  14. data/lib/selenium/webdriver/chrome/options.rb +127 -52
  15. data/lib/selenium/webdriver/chrome/profile.rb +8 -5
  16. data/lib/selenium/webdriver/chrome/service.rb +4 -6
  17. data/lib/selenium/webdriver/chrome.rb +10 -9
  18. data/lib/selenium/webdriver/common/driver.rb +110 -19
  19. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
  20. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +77 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +38 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +45 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +43 -0
  26. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
  28. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +144 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_logs.rb +30 -0
  30. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
  32. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +136 -0
  33. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
  34. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
  35. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +1 -0
  36. data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
  37. data/lib/selenium/webdriver/common/element.rb +79 -16
  38. data/lib/selenium/webdriver/common/error.rb +12 -0
  39. data/lib/selenium/webdriver/common/interactions/interaction.rb +4 -1
  40. data/lib/selenium/webdriver/common/log_entry.rb +2 -2
  41. data/lib/selenium/webdriver/common/logger.rb +50 -15
  42. data/lib/selenium/webdriver/common/manager.rb +14 -14
  43. data/lib/selenium/webdriver/common/options.rb +186 -0
  44. data/lib/selenium/webdriver/common/platform.rb +6 -1
  45. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  46. data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
  47. data/lib/selenium/webdriver/common/proxy.rb +6 -3
  48. data/lib/selenium/webdriver/common/search_context.rb +7 -3
  49. data/lib/selenium/webdriver/common/service.rb +23 -113
  50. data/lib/selenium/webdriver/common/service_manager.rb +151 -0
  51. data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
  52. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  53. data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
  54. data/lib/selenium/webdriver/common/target_locator.rb +32 -4
  55. data/lib/selenium/webdriver/common/timeouts.rb +31 -4
  56. data/lib/selenium/webdriver/common/wait.rb +1 -1
  57. data/lib/selenium/webdriver/common/window.rb +0 -4
  58. data/lib/selenium/webdriver/common.rb +17 -2
  59. data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
  60. data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
  61. data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
  62. data/lib/selenium/webdriver/{chrome/bridge.rb → devtools/pinned_script.rb} +26 -17
  63. data/lib/selenium/webdriver/devtools/request.rb +67 -0
  64. data/lib/selenium/webdriver/devtools/response.rb +66 -0
  65. data/lib/selenium/webdriver/devtools.rb +182 -0
  66. data/lib/selenium/webdriver/edge/driver.rb +5 -31
  67. data/lib/selenium/webdriver/edge/features.rb +44 -0
  68. data/lib/selenium/webdriver/edge/options.rb +11 -48
  69. data/lib/selenium/webdriver/edge/profile.rb +33 -0
  70. data/lib/selenium/webdriver/edge/service.rb +9 -24
  71. data/lib/selenium/webdriver/edge.rb +11 -13
  72. data/lib/selenium/webdriver/firefox/driver.rb +20 -30
  73. data/lib/selenium/webdriver/firefox/extension.rb +8 -0
  74. data/lib/selenium/webdriver/firefox/{bridge.rb → features.rb} +23 -4
  75. data/lib/selenium/webdriver/firefox/options.rb +70 -49
  76. data/lib/selenium/webdriver/firefox/profile.rb +16 -77
  77. data/lib/selenium/webdriver/firefox/service.rb +1 -5
  78. data/lib/selenium/webdriver/firefox.rb +22 -16
  79. data/lib/selenium/webdriver/ie/driver.rb +1 -34
  80. data/lib/selenium/webdriver/ie/options.rb +13 -44
  81. data/lib/selenium/webdriver/ie/service.rb +9 -11
  82. data/lib/selenium/webdriver/ie.rb +8 -7
  83. data/lib/selenium/webdriver/remote/bridge.rb +112 -86
  84. data/lib/selenium/webdriver/remote/capabilities.rb +120 -62
  85. data/lib/selenium/webdriver/remote/commands.rb +7 -0
  86. data/lib/selenium/webdriver/remote/driver.rb +15 -12
  87. data/lib/selenium/webdriver/remote/http/common.rb +0 -5
  88. data/lib/selenium/webdriver/remote/http/default.rb +17 -11
  89. data/lib/selenium/webdriver/remote/http/persistent.rb +11 -6
  90. data/lib/selenium/webdriver/remote.rb +15 -9
  91. data/lib/selenium/webdriver/safari/driver.rb +3 -34
  92. data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +6 -6
  93. data/lib/selenium/webdriver/safari/options.rb +10 -29
  94. data/lib/selenium/webdriver/safari/service.rb +0 -4
  95. data/lib/selenium/webdriver/safari.rb +16 -8
  96. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
  97. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
  98. data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
  99. data/lib/selenium/webdriver/support/color.rb +2 -2
  100. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  101. data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
  102. data/lib/selenium/webdriver/support/guards/guard_condition.rb +52 -0
  103. data/lib/selenium/webdriver/support/guards.rb +95 -0
  104. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  105. data/lib/selenium/webdriver/support/select.rb +2 -2
  106. data/lib/selenium/webdriver/support.rb +1 -0
  107. data/lib/selenium/webdriver/version.rb +1 -1
  108. data/lib/selenium/webdriver.rb +10 -8
  109. data/selenium-webdriver.gemspec +29 -13
  110. metadata +125 -51
  111. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
  112. data/lib/selenium/webdriver/firefox/binary.rb +0 -110
  113. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
@@ -30,6 +30,7 @@ module Selenium
30
30
 
31
31
  class Driver
32
32
  include SearchContext
33
+ include TakesScreenshot
33
34
 
34
35
  class << self
35
36
  #
@@ -43,17 +44,17 @@ module Selenium
43
44
  def for(browser, opts = {})
44
45
  case browser
45
46
  when :chrome
46
- Chrome::Driver.new(opts)
47
+ Chrome::Driver.new(**opts)
47
48
  when :internet_explorer, :ie
48
- IE::Driver.new(opts)
49
+ IE::Driver.new(**opts)
49
50
  when :safari
50
- Safari::Driver.new(opts)
51
+ Safari::Driver.new(**opts)
51
52
  when :firefox, :ff
52
- Firefox::Driver.new(opts)
53
+ Firefox::Driver.new(**opts)
53
54
  when :edge
54
- Edge::Driver.new(opts)
55
+ Edge::Driver.new(**opts)
55
56
  when :remote
56
- Remote::Driver.new(opts)
57
+ Remote::Driver.new(**opts)
57
58
  else
58
59
  raise ArgumentError, "unknown driver: #{browser.inspect}"
59
60
  end
@@ -67,13 +68,27 @@ module Selenium
67
68
  # @api private
68
69
  #
69
70
 
70
- def initialize(bridge, listener: nil)
71
- @bridge = bridge
72
- @bridge = Support::EventFiringBridge.new(bridge, listener) if listener
71
+ def initialize(bridge: nil, listener: nil, **opts)
72
+ @service = nil
73
+ @devtools = nil
74
+ bridge ||= create_bridge(**opts)
75
+ add_extensions(bridge.browser)
76
+ @bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
73
77
  end
74
78
 
75
79
  def inspect
76
- format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2, browser: bridge.browser.inspect
80
+ format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2,
81
+ browser: bridge.browser.inspect
82
+ end
83
+
84
+ #
85
+ # information about whether a remote end is in a state in which it can create new sessions,
86
+ # and may include additional meta information.
87
+ #
88
+ # @return [Hash]
89
+ #
90
+ def status
91
+ @bridge.status
77
92
  end
78
93
 
79
94
  #
@@ -164,6 +179,9 @@ module Selenium
164
179
 
165
180
  def quit
166
181
  bridge.quit
182
+ ensure
183
+ @service&.stop
184
+ @devtools&.close
167
185
  end
168
186
 
169
187
  #
@@ -269,7 +287,7 @@ module Selenium
269
287
  end
270
288
 
271
289
  def browser
272
- bridge.browser
290
+ bridge&.browser
273
291
  end
274
292
 
275
293
  def capabilities
@@ -281,26 +299,99 @@ module Selenium
281
299
  # @see SearchContext
282
300
  #
283
301
 
284
- def ref; end
302
+ def ref
303
+ [:driver, nil]
304
+ end
285
305
 
286
306
  private
287
307
 
288
308
  attr_reader :bridge
289
309
 
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
323
+ 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
+ end
343
+
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
+
290
362
  def service_url(opts)
291
- @service = opts.delete(:service)
363
+ service_config = opts.delete(:service)
292
364
  %i[driver_opts driver_path port].each do |key|
293
365
  next unless opts.key? key
294
366
 
295
- WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service')
367
+ WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service',
368
+ id: "service_#{key}".to_sym)
296
369
  end
297
- @service ||= Service.send(browser,
298
- args: opts.delete(:driver_opts),
299
- path: opts.delete(:driver_path),
300
- port: opts.delete(:port))
301
- @service.start
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
302
375
  @service.uri
303
376
  end
377
+
378
+ def screenshot
379
+ bridge.screenshot
380
+ end
381
+
382
+ def add_extensions(browser)
383
+ extensions = case browser
384
+ when :chrome, :msedge
385
+ Chrome::Driver::EXTENSIONS
386
+ when :firefox
387
+ Firefox::Driver::EXTENSIONS
388
+ when :safari, :safari_technology_preview
389
+ Safari::Driver::EXTENSIONS
390
+ else
391
+ []
392
+ end
393
+ extensions.each { |extension| extend extension }
394
+ end
304
395
  end # Driver
305
396
  end # WebDriver
306
397
  end # Selenium
@@ -0,0 +1,43 @@
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 FullPageScreenshot
24
+ #
25
+ # Save a PNG screenshot of the full page to the given path
26
+ #
27
+ # @api public
28
+ #
29
+
30
+ def save_full_page_screenshot(path)
31
+ save_screenshot(path, full_page: true)
32
+ end
33
+
34
+ private
35
+
36
+ def full_screenshot
37
+ @bridge.full_screenshot
38
+ end
39
+
40
+ end # FullPageScreenshot
41
+ end # DriverExtensions
42
+ end # WebDriver
43
+ end # Selenium
@@ -0,0 +1,51 @@
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 HasApplePermissions
24
+
25
+ #
26
+ # Returns permissions.
27
+ #
28
+ # @return [Hash]
29
+ #
30
+
31
+ def permissions
32
+ @bridge.permissions
33
+ end
34
+
35
+ #
36
+ # Sets permissions.
37
+ #
38
+ # @example
39
+ # driver.permissions = {'getUserMedia' => true}
40
+ #
41
+ # @param [Hash<Symbol, Boolean>] permissions
42
+ #
43
+
44
+ def permissions=(permissions)
45
+ @bridge.permissions = permissions
46
+ end
47
+
48
+ end # HasPermissions
49
+ end # DriverExtensions
50
+ end # WebDriver
51
+ end # Selenium
@@ -0,0 +1,89 @@
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 HasAuthentication
24
+
25
+ #
26
+ # Registers basic authentication handler which is automatically
27
+ # used whenever browser gets an authentication required response.
28
+ # This currently relies on DevTools so is only supported in
29
+ # Chromium browsers.
30
+ #
31
+ # @example Authenticate any request
32
+ # driver.register(username: 'admin', password: '123456')
33
+ #
34
+ # @example Authenticate based on URL
35
+ # driver.register(username: 'admin1', password: '123456', uri: /mysite1\.com/)
36
+ # driver.register(username: 'admin2', password: '123456', uri: /mysite2\.com/)
37
+ #
38
+ # @param [String] username
39
+ # @param [String] password
40
+ # @param [Regexp] uri to associate the credentials with
41
+ #
42
+
43
+ def register(username:, password:, uri: //)
44
+ auth_handlers << {username: username, password: password, uri: uri}
45
+
46
+ devtools.network.set_cache_disabled(cache_disabled: true)
47
+ devtools.fetch.on(:auth_required) do |params|
48
+ authenticate(params['requestId'], params.dig('request', 'url'))
49
+ end
50
+ devtools.fetch.on(:request_paused) do |params|
51
+ devtools.fetch.continue_request(request_id: params['requestId'])
52
+ end
53
+ devtools.fetch.enable(handle_auth_requests: true)
54
+ end
55
+
56
+ private
57
+
58
+ def auth_handlers
59
+ @auth_handlers ||= []
60
+ end
61
+
62
+ def authenticate(request_id, url)
63
+ credentials = auth_handlers.find do |handler|
64
+ url.match?(handler[:uri])
65
+ end
66
+
67
+ if credentials
68
+ devtools.fetch.continue_with_auth(
69
+ request_id: request_id,
70
+ auth_challenge_response: {
71
+ response: 'ProvideCredentials',
72
+ username: credentials[:username],
73
+ password: credentials[:password]
74
+ }
75
+ )
76
+ else
77
+ devtools.fetch.continue_with_auth(
78
+ request_id: request_id,
79
+ auth_challenge_response: {
80
+ response: 'CancelAuth'
81
+ }
82
+ )
83
+ end
84
+ end
85
+
86
+ end # HasAuthentication
87
+ end # DriverExtensions
88
+ end # WebDriver
89
+ end # Selenium
@@ -0,0 +1,77 @@
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 HasCasting
24
+
25
+ #
26
+ # What devices ("sinks") are available to be cast to.
27
+ #
28
+ # @return [Array] list of sinks available for casting with id and name values
29
+ #
30
+
31
+ def cast_sinks
32
+ @bridge.cast_sinks
33
+ end
34
+
35
+ #
36
+ # Sets a specific sink, using its name, as a Cast session receiver target.
37
+ #
38
+ # @param [String] name the sink to use as the target
39
+ #
40
+
41
+ def cast_sink_to_use=(name)
42
+ @bridge.cast_sink_to_use = name
43
+ end
44
+
45
+ #
46
+ # Starts a tab mirroring session on a specific receiver target.
47
+ #
48
+ # @param [String] name the sink to use as the target
49
+ #
50
+
51
+ def start_cast_tab_mirroring(name)
52
+ @bridge.start_cast_tab_mirroring(name)
53
+ end
54
+
55
+ #
56
+ # Gets error messages when there is any issue in a Cast session.
57
+ #
58
+ # @return [String] the error message
59
+ #
60
+
61
+ def cast_issue_message
62
+ @bridge.cast_issue_message
63
+ end
64
+
65
+ #
66
+ # Stops the existing Cast session on a specific receiver target.
67
+ #
68
+ # @param [String] name the sink to stop the Cast session
69
+ #
70
+
71
+ def stop_casting(name)
72
+ @bridge.stop_casting(name)
73
+ end
74
+ end # HasCasting
75
+ end # DriverExtensions
76
+ end # WebDriver
77
+ end # Selenium
@@ -0,0 +1,38 @@
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 HasCDP
24
+
25
+ #
26
+ # Returns network conditions.
27
+ #
28
+ # @return [Hash]
29
+ #
30
+
31
+ def execute_cdp(cmd, **params)
32
+ @bridge.send_command(cmd: cmd, params: params)
33
+ end
34
+
35
+ end # HasCDP
36
+ end # DriverExtensions
37
+ end # WebDriver
38
+ end # Selenium
@@ -0,0 +1,45 @@
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 HasContext
24
+
25
+ #
26
+ # Sets the context that Selenium commands are running in using
27
+ # a `with` statement. The state of the context on the server is
28
+ # saved before entering the block, and restored upon exiting it.
29
+ #
30
+ # @param [String] name which permission to set
31
+ # @param [String] value what to set the permission to
32
+ #
33
+
34
+ def context=(value)
35
+ @bridge.context = value
36
+ end
37
+
38
+ def context
39
+ @bridge.context
40
+ end
41
+
42
+ end # HasContext
43
+ end # DriverExtensions
44
+ end # WebDriver
45
+ end # Selenium
@@ -0,0 +1,43 @@
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 HasDevTools
24
+
25
+ #
26
+ # Retrieves connection to DevTools.
27
+ #
28
+ # @return [DevTools]
29
+ #
30
+
31
+ def devtools
32
+ @devtools ||= begin
33
+ require 'selenium/devtools'
34
+ Selenium::DevTools.version ||= devtools_version
35
+ Selenium::DevTools.load_version
36
+ Selenium::WebDriver::DevTools.new(url: devtools_url)
37
+ end
38
+ end
39
+
40
+ end # HasDevTools
41
+ end # DriverExtensions
42
+ end # WebDriver
43
+ end # Selenium
@@ -0,0 +1,38 @@
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 HasLaunching
24
+
25
+ #
26
+ # Launches Chromium app specified by id.
27
+ #
28
+ # @param [String] id
29
+ #
30
+
31
+ def launch_app(id)
32
+ @bridge.launch_app(id)
33
+ end
34
+
35
+ end # HasLaunching
36
+ end # DriverExtensions
37
+ end # WebDriver
38
+ end # Selenium
@@ -17,23 +17,20 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
+ # TODO: Deprecated; Delete after 4.0 release
20
21
  module Selenium
21
22
  module WebDriver
22
23
  module DriverExtensions
23
24
  module HasLocation
24
25
  def location
25
- @bridge.location
26
+ raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
26
27
  end
27
28
 
28
- def location=(loc)
29
- raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
30
-
31
- @bridge.set_location loc.latitude, loc.longitude, loc.altitude
29
+ def location=(*)
30
+ raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
32
31
  end
32
+ alias_method :set_location, :location
33
33
 
34
- def set_location(lat, lon, alt)
35
- self.location = Location.new(Float(lat), Float(lon), Float(alt))
36
- end
37
34
  end # HasLocation
38
35
  end # DriverExtensions
39
36
  end # WebDriver