selenium-webdriver 3.142.7 → 4.3.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.
- checksums.yaml +5 -5
- data/CHANGES +432 -5
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- data/lib/selenium/server.rb +75 -64
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/bidi/session.rb +38 -0
- data/lib/selenium/webdriver/bidi.rb +55 -0
- data/lib/selenium/webdriver/chrome/driver.rb +26 -83
- data/lib/selenium/webdriver/chrome/{bridge.rb → features.rb} +55 -12
- data/lib/selenium/webdriver/chrome/options.rb +138 -67
- data/lib/selenium/webdriver/chrome/profile.rb +6 -3
- data/lib/selenium/webdriver/chrome/service.rb +8 -15
- data/lib/selenium/webdriver/chrome.rb +5 -18
- data/lib/selenium/webdriver/common/action_builder.rb +171 -236
- data/lib/selenium/webdriver/common/driver.rb +76 -29
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +10 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +87 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +44 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +144 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_logs.rb} +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +136 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/element.rb +83 -23
- data/lib/selenium/webdriver/common/error.rb +32 -196
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -22
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +10 -6
- data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
- data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
- data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +68 -78
- data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
- data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
- data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
- data/lib/selenium/webdriver/common/interactions/scroll.rb +57 -0
- data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
- data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
- data/lib/selenium/webdriver/common/{w3c_manager.rb → interactions/wheel_input.rb} +14 -17
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/log_entry.rb +2 -2
- data/lib/selenium/webdriver/common/logger.rb +50 -15
- data/lib/selenium/webdriver/common/manager.rb +11 -38
- data/lib/selenium/webdriver/common/options.rb +147 -23
- data/lib/selenium/webdriver/common/platform.rb +10 -5
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
- data/lib/selenium/webdriver/common/proxy.rb +6 -3
- data/lib/selenium/webdriver/common/search_context.rb +7 -9
- data/lib/selenium/webdriver/common/service.rb +17 -125
- data/lib/selenium/webdriver/common/service_manager.rb +150 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
- data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
- data/lib/selenium/webdriver/common/target_locator.rb +32 -4
- data/lib/selenium/webdriver/common/timeouts.rb +31 -4
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +149 -0
- data/lib/selenium/webdriver/common/window.rb +0 -4
- data/lib/selenium/webdriver/common/zipper.rb +3 -9
- data/lib/selenium/webdriver/common.rb +35 -18
- data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +59 -0
- data/lib/selenium/webdriver/devtools/request.rb +67 -0
- data/lib/selenium/webdriver/devtools/response.rb +66 -0
- data/lib/selenium/webdriver/devtools.rb +86 -0
- data/lib/selenium/webdriver/edge/driver.rb +7 -29
- data/lib/selenium/webdriver/edge/features.rb +45 -0
- data/lib/selenium/webdriver/edge/options.rb +11 -48
- data/lib/selenium/webdriver/edge/profile.rb +33 -0
- data/lib/selenium/webdriver/edge/service.rb +10 -26
- data/lib/selenium/webdriver/edge.rb +11 -14
- data/lib/selenium/webdriver/firefox/driver.rb +32 -19
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/features.rb +63 -0
- data/lib/selenium/webdriver/firefox/options.rb +73 -50
- data/lib/selenium/webdriver/firefox/profile.rb +16 -70
- data/lib/selenium/webdriver/firefox/service.rb +5 -9
- data/lib/selenium/webdriver/firefox/util.rb +1 -1
- data/lib/selenium/webdriver/firefox.rb +17 -28
- data/lib/selenium/webdriver/ie/driver.rb +1 -47
- data/lib/selenium/webdriver/ie/options.rb +15 -46
- data/lib/selenium/webdriver/ie/service.rb +13 -15
- data/lib/selenium/webdriver/ie.rb +3 -16
- data/lib/selenium/webdriver/remote/bridge.rb +563 -86
- data/lib/selenium/webdriver/remote/capabilities.rb +159 -123
- data/lib/selenium/webdriver/remote/commands.rb +158 -0
- data/lib/selenium/webdriver/remote/driver.rb +22 -13
- data/lib/selenium/webdriver/remote/http/common.rb +0 -5
- data/lib/selenium/webdriver/remote/http/default.rb +22 -31
- data/lib/selenium/webdriver/remote/response.rb +18 -49
- data/lib/selenium/webdriver/remote.rb +15 -12
- data/lib/selenium/webdriver/safari/driver.rb +3 -31
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -3
- data/lib/selenium/webdriver/safari/options.rb +10 -29
- data/lib/selenium/webdriver/safari/service.rb +4 -8
- data/lib/selenium/webdriver/safari.rb +13 -19
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
- data/lib/selenium/webdriver/support/color.rb +9 -9
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
- data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +22 -19
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/support/select.rb +3 -3
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +14 -13
- data/selenium-webdriver.gemspec +32 -13
- metadata +176 -69
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
- data/lib/selenium/webdriver/common/keyboard.rb +0 -70
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/firefox/binary.rb +0 -187
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -60
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
|
@@ -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,19 +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
|
-
when :phantomjs
|
|
52
|
-
PhantomJS::Driver.new(opts)
|
|
51
|
+
Safari::Driver.new(**opts)
|
|
53
52
|
when :firefox, :ff
|
|
54
|
-
Firefox::Driver.new(opts)
|
|
53
|
+
Firefox::Driver.new(**opts)
|
|
55
54
|
when :edge
|
|
56
|
-
Edge::Driver.new(opts)
|
|
55
|
+
Edge::Driver.new(**opts)
|
|
57
56
|
when :remote
|
|
58
|
-
Remote::Driver.new(opts)
|
|
57
|
+
Remote::Driver.new(**opts)
|
|
59
58
|
else
|
|
60
59
|
raise ArgumentError, "unknown driver: #{browser.inspect}"
|
|
61
60
|
end
|
|
@@ -69,13 +68,27 @@ module Selenium
|
|
|
69
68
|
# @api private
|
|
70
69
|
#
|
|
71
70
|
|
|
72
|
-
def initialize(bridge, listener: nil)
|
|
73
|
-
@
|
|
74
|
-
@
|
|
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
|
|
75
77
|
end
|
|
76
78
|
|
|
77
79
|
def inspect
|
|
78
|
-
format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2,
|
|
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
|
|
79
92
|
end
|
|
80
93
|
|
|
81
94
|
#
|
|
@@ -106,12 +119,12 @@ module Selenium
|
|
|
106
119
|
end
|
|
107
120
|
|
|
108
121
|
#
|
|
109
|
-
# @return [ActionBuilder
|
|
110
|
-
# @see ActionBuilder
|
|
122
|
+
# @return [ActionBuilder]
|
|
123
|
+
# @see ActionBuilder
|
|
111
124
|
#
|
|
112
125
|
|
|
113
|
-
def action
|
|
114
|
-
bridge.action
|
|
126
|
+
def action(**opts)
|
|
127
|
+
bridge.action(**opts)
|
|
115
128
|
end
|
|
116
129
|
|
|
117
130
|
def mouse
|
|
@@ -166,6 +179,9 @@ module Selenium
|
|
|
166
179
|
|
|
167
180
|
def quit
|
|
168
181
|
bridge.quit
|
|
182
|
+
ensure
|
|
183
|
+
@service&.stop
|
|
184
|
+
@devtools&.close
|
|
169
185
|
end
|
|
170
186
|
|
|
171
187
|
#
|
|
@@ -271,7 +287,7 @@ module Selenium
|
|
|
271
287
|
end
|
|
272
288
|
|
|
273
289
|
def browser
|
|
274
|
-
bridge
|
|
290
|
+
bridge&.browser
|
|
275
291
|
end
|
|
276
292
|
|
|
277
293
|
def capabilities
|
|
@@ -283,26 +299,57 @@ module Selenium
|
|
|
283
299
|
# @see SearchContext
|
|
284
300
|
#
|
|
285
301
|
|
|
286
|
-
def ref
|
|
302
|
+
def ref
|
|
303
|
+
[:driver, nil]
|
|
304
|
+
end
|
|
287
305
|
|
|
288
306
|
private
|
|
289
307
|
|
|
290
308
|
attr_reader :bridge
|
|
291
309
|
|
|
292
|
-
def
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service')
|
|
310
|
+
def create_bridge(capabilities: nil, options: nil, url: nil, service: nil, http_client: nil)
|
|
311
|
+
Remote::Bridge.new(http_client: http_client,
|
|
312
|
+
url: url || service_url(service)).tap do |bridge|
|
|
313
|
+
generated_caps = options ? options.as_json : generate_capabilities(capabilities)
|
|
314
|
+
bridge.create_session(generated_caps)
|
|
298
315
|
end
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
def generate_capabilities(capabilities)
|
|
319
|
+
Array(capabilities).map { |cap|
|
|
320
|
+
if cap.is_a? Symbol
|
|
321
|
+
cap = Remote::Capabilities.send(cap)
|
|
322
|
+
elsif !cap.respond_to? :as_json
|
|
323
|
+
msg = ":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not"
|
|
324
|
+
raise ArgumentError, msg
|
|
325
|
+
end
|
|
326
|
+
cap.as_json
|
|
327
|
+
}.inject(:merge) || Remote::Capabilities.send(browser || :new)
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def service_url(service)
|
|
331
|
+
service ||= Service.send(browser)
|
|
332
|
+
@service = service.launch
|
|
304
333
|
@service.uri
|
|
305
334
|
end
|
|
335
|
+
|
|
336
|
+
def screenshot
|
|
337
|
+
bridge.screenshot
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def add_extensions(browser)
|
|
341
|
+
extensions = case browser
|
|
342
|
+
when :chrome, :msedge
|
|
343
|
+
Chrome::Driver::EXTENSIONS
|
|
344
|
+
when :firefox
|
|
345
|
+
Firefox::Driver::EXTENSIONS
|
|
346
|
+
when :safari, :safari_technology_preview
|
|
347
|
+
Safari::Driver::EXTENSIONS
|
|
348
|
+
else
|
|
349
|
+
[]
|
|
350
|
+
end
|
|
351
|
+
extensions.each { |extension| extend extension }
|
|
352
|
+
end
|
|
306
353
|
end # Driver
|
|
307
354
|
end # WebDriver
|
|
308
355
|
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
|
|
@@ -20,17 +20,19 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module DriverExtensions
|
|
23
|
-
module
|
|
24
|
-
def touch
|
|
25
|
-
TouchActionBuilder.new Mouse.new(@bridge), Keyboard.new(@bridge), touch_screen
|
|
26
|
-
end
|
|
23
|
+
module HasBiDi
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
#
|
|
26
|
+
# Retrieves WebDriver BiDi connection.
|
|
27
|
+
#
|
|
28
|
+
# @return [BiDi]
|
|
29
|
+
#
|
|
29
30
|
|
|
30
|
-
def
|
|
31
|
-
|
|
31
|
+
def bidi
|
|
32
|
+
@bidi ||= Selenium::WebDriver::BiDi.new(url: capabilities[:web_socket_url])
|
|
32
33
|
end
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
end # HasBiDi
|
|
34
36
|
end # DriverExtensions
|
|
35
37
|
end # WebDriver
|
|
36
38
|
end # Selenium
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
# Starts a tab mirroring session on a specific receiver target.
|
|
57
|
+
#
|
|
58
|
+
# @param [String] name the sink to use as the target
|
|
59
|
+
#
|
|
60
|
+
|
|
61
|
+
def start_cast_desktop_mirroring(name)
|
|
62
|
+
@bridge.start_cast_desktop_mirroring(name)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
# Gets error messages when there is any issue in a Cast session.
|
|
67
|
+
#
|
|
68
|
+
# @return [String] the error message
|
|
69
|
+
#
|
|
70
|
+
|
|
71
|
+
def cast_issue_message
|
|
72
|
+
@bridge.cast_issue_message
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# Stops the existing Cast session on a specific receiver target.
|
|
77
|
+
#
|
|
78
|
+
# @param [String] name the sink to stop the Cast session
|
|
79
|
+
#
|
|
80
|
+
|
|
81
|
+
def stop_casting(name)
|
|
82
|
+
@bridge.stop_casting(name)
|
|
83
|
+
end
|
|
84
|
+
end # HasCasting
|
|
85
|
+
end # DriverExtensions
|
|
86
|
+
end # WebDriver
|
|
87
|
+
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,44 @@
|
|
|
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] value which context gets set (either 'chrome' or 'content')
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
def context=(value)
|
|
34
|
+
@bridge.context = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def context
|
|
38
|
+
@bridge.context
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end # HasContext
|
|
42
|
+
end # DriverExtensions
|
|
43
|
+
end # WebDriver
|
|
44
|
+
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
|
-
|
|
26
|
+
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
def location=(
|
|
29
|
-
raise
|
|
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
|