selenium-webdriver 4.4.0 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +86 -1
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/server.rb +20 -16
- data/lib/selenium/webdriver/atoms/findElements.js +0 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +0 -0
- data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
- data/lib/selenium/webdriver/atoms.rb +2 -3
- data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
- data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log_inspector.rb +140 -0
- data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
- data/lib/selenium/webdriver/bidi/session.rb +13 -0
- data/lib/selenium/webdriver/bidi.rb +2 -1
- data/lib/selenium/webdriver/chrome/driver.rb +19 -28
- data/lib/selenium/webdriver/chrome/features.rb +5 -72
- data/lib/selenium/webdriver/chrome/options.rb +3 -237
- data/lib/selenium/webdriver/chrome/profile.rb +3 -83
- data/lib/selenium/webdriver/chrome/service.rb +4 -19
- data/lib/selenium/webdriver/chromium/driver.rb +61 -0
- data/lib/selenium/webdriver/chromium/features.rb +103 -0
- data/lib/selenium/webdriver/chromium/options.rb +261 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium/service.rb +42 -0
- data/lib/selenium/webdriver/chromium.rb +32 -0
- data/lib/selenium/webdriver/common/action_builder.rb +11 -48
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +34 -25
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_bidi.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +1 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +0 -2
- data/lib/selenium/webdriver/common/element.rb +7 -7
- data/lib/selenium/webdriver/common/error.rb +0 -2
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +3 -3
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/scroll.rb +7 -5
- data/lib/selenium/webdriver/common/logger.rb +10 -2
- data/lib/selenium/webdriver/common/options.rb +30 -8
- data/lib/selenium/webdriver/common/platform.rb +4 -1
- data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
- data/lib/selenium/webdriver/common/proxy.rb +1 -1
- data/lib/selenium/webdriver/common/selenium_manager.rb +89 -0
- data/lib/selenium/webdriver/common/service.rb +16 -8
- data/lib/selenium/webdriver/common/service_manager.rb +2 -10
- data/lib/selenium/webdriver/common/shadow_root.rb +1 -2
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
- data/lib/selenium/webdriver/common/target_locator.rb +2 -3
- data/lib/selenium/webdriver/common/timeouts.rb +2 -2
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +8 -6
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +0 -1
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +16 -16
- data/lib/selenium/webdriver/common/websocket_connection.rb +10 -2
- data/lib/selenium/webdriver/common.rb +2 -0
- data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +3 -6
- data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
- data/lib/selenium/webdriver/devtools/request.rb +0 -2
- data/lib/selenium/webdriver/devtools/response.rb +0 -2
- data/lib/selenium/webdriver/devtools.rb +0 -1
- data/lib/selenium/webdriver/edge/driver.rb +20 -3
- data/lib/selenium/webdriver/edge/features.rb +3 -4
- data/lib/selenium/webdriver/edge/options.rb +3 -5
- data/lib/selenium/webdriver/edge/profile.rb +2 -2
- data/lib/selenium/webdriver/edge/service.rb +2 -2
- data/lib/selenium/webdriver/firefox/driver.rb +19 -2
- data/lib/selenium/webdriver/firefox/features.rb +5 -2
- data/lib/selenium/webdriver/firefox/options.rb +6 -2
- data/lib/selenium/webdriver/firefox/profile.rb +6 -6
- data/lib/selenium/webdriver/firefox/service.rb +0 -1
- data/lib/selenium/webdriver/ie/driver.rb +20 -1
- data/lib/selenium/webdriver/ie/service.rb +1 -2
- data/lib/selenium/webdriver/remote/bridge.rb +8 -15
- data/lib/selenium/webdriver/remote/capabilities.rb +34 -12
- data/lib/selenium/webdriver/remote/commands.rb +0 -2
- data/lib/selenium/webdriver/remote/driver.rb +13 -13
- data/lib/selenium/webdriver/remote/http/curb.rb +0 -2
- data/lib/selenium/webdriver/remote/http/default.rb +1 -0
- data/lib/selenium/webdriver/remote/response.rb +0 -1
- data/lib/selenium/webdriver/safari/driver.rb +20 -1
- data/lib/selenium/webdriver/safari/features.rb +0 -2
- data/lib/selenium/webdriver/safari/options.rb +5 -1
- data/lib/selenium/webdriver/safari.rb +1 -1
- data/lib/selenium/webdriver/support/color.rb +15 -15
- data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
- data/lib/selenium/webdriver/support/guards/guard_condition.rb +0 -2
- data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
- data/lib/selenium/webdriver/support/select.rb +3 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +3 -4
- data/selenium-webdriver.gemspec +8 -9
- metadata +29 -73
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -0,0 +1,124 @@
|
|
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
|
+
#
|
23
|
+
# @api private
|
24
|
+
#
|
25
|
+
|
26
|
+
class ChildProcess
|
27
|
+
TimeoutError = Class.new(StandardError)
|
28
|
+
|
29
|
+
SIGTERM = 'TERM'
|
30
|
+
SIGKILL = 'KILL'
|
31
|
+
|
32
|
+
POLL_INTERVAL = 0.1
|
33
|
+
|
34
|
+
attr_accessor :detach
|
35
|
+
attr_writer :io
|
36
|
+
|
37
|
+
def self.build(*command)
|
38
|
+
new(*command)
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(*command)
|
42
|
+
@command = command
|
43
|
+
@detach = false
|
44
|
+
@pid = nil
|
45
|
+
@status = nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def io
|
49
|
+
@io ||= Platform.null_device
|
50
|
+
end
|
51
|
+
|
52
|
+
def start
|
53
|
+
options = {%i[out err] => io}
|
54
|
+
options[:pgroup] = true unless Platform.windows? # NOTE: this is a bug only in Windows 7
|
55
|
+
|
56
|
+
WebDriver.logger.debug("Starting process: #{@command} with #{options}")
|
57
|
+
@pid = Process.spawn(*@command, options)
|
58
|
+
WebDriver.logger.debug(" -> pid: #{@pid}")
|
59
|
+
|
60
|
+
Process.detach(@pid) if detach
|
61
|
+
end
|
62
|
+
|
63
|
+
def stop(timeout = 3)
|
64
|
+
return unless @pid
|
65
|
+
return if exited?
|
66
|
+
|
67
|
+
WebDriver.logger.debug("Sending TERM to process: #{@pid}")
|
68
|
+
terminate(@pid)
|
69
|
+
poll_for_exit(timeout)
|
70
|
+
|
71
|
+
WebDriver.logger.debug(" -> stopped #{@pid}")
|
72
|
+
rescue TimeoutError, Errno::EINVAL
|
73
|
+
WebDriver.logger.debug(" -> sending KILL to process: #{@pid}")
|
74
|
+
kill(@pid)
|
75
|
+
wait
|
76
|
+
WebDriver.logger.debug(" -> killed #{@pid}")
|
77
|
+
end
|
78
|
+
|
79
|
+
def alive?
|
80
|
+
@pid && !exited?
|
81
|
+
end
|
82
|
+
|
83
|
+
def exited?
|
84
|
+
return unless @pid
|
85
|
+
|
86
|
+
WebDriver.logger.debug("Checking if #{@pid} is exited:")
|
87
|
+
_, @status = Process.waitpid2(@pid, Process::WNOHANG | Process::WUNTRACED) if @status.nil?
|
88
|
+
return if @status.nil?
|
89
|
+
|
90
|
+
exit_code = @status.exitstatus || @status.termsig
|
91
|
+
WebDriver.logger.debug(" -> exit code is #{exit_code.inspect}")
|
92
|
+
|
93
|
+
!!exit_code
|
94
|
+
end
|
95
|
+
|
96
|
+
def poll_for_exit(timeout)
|
97
|
+
WebDriver.logger.debug("Polling #{timeout} seconds for exit of #{@pid}")
|
98
|
+
|
99
|
+
end_time = Time.now + timeout
|
100
|
+
sleep POLL_INTERVAL until exited? || Time.now > end_time
|
101
|
+
|
102
|
+
raise TimeoutError, " -> #{@pid} still alive after #{timeout} seconds" unless exited?
|
103
|
+
end
|
104
|
+
|
105
|
+
def wait
|
106
|
+
return if exited?
|
107
|
+
|
108
|
+
_, @status = Process.waitpid2(@pid)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def terminate(pid)
|
114
|
+
Process.kill(SIGTERM, pid)
|
115
|
+
end
|
116
|
+
|
117
|
+
def kill(pid)
|
118
|
+
Process.kill(SIGKILL, pid)
|
119
|
+
rescue Errno::ECHILD, Errno::ESRCH
|
120
|
+
# already dead
|
121
|
+
end
|
122
|
+
end # ChildProcess
|
123
|
+
end # WebDriver
|
124
|
+
end # Selenium
|
@@ -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
|
-
@
|
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
|
-
@
|
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
|
-
|
258
|
+
alias first find_element
|
267
259
|
|
268
260
|
#
|
269
261
|
# driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
|
270
262
|
#
|
271
263
|
|
272
|
-
|
264
|
+
alias all find_elements
|
273
265
|
|
274
266
|
#
|
275
267
|
# driver.script('function() { ... };')
|
276
268
|
#
|
277
269
|
|
278
|
-
|
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(
|
320
|
-
Remote::Bridge.new(http_client: http_client,
|
321
|
-
|
322
|
-
|
323
|
-
|
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 =
|
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)
|
344
|
+
}.inject(:merge)
|
337
345
|
end
|
338
346
|
|
339
347
|
def service_url(service)
|
340
|
-
|
341
|
-
@
|
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
|
-
|
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
|
@@ -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 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
|
-
|
33
|
-
|
32
|
+
alias set_location location
|
34
33
|
end # HasLocation
|
35
34
|
end # DriverExtensions
|
36
35
|
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
|
-
|
46
|
+
alias eql? ==
|
47
47
|
|
48
48
|
def hash
|
49
49
|
[@id, @bridge].hash
|
@@ -101,7 +101,7 @@ module Selenium
|
|
101
101
|
# if it exists. If it does not, then the value of the attribute with the given name is returned.
|
102
102
|
# If neither exists, null is returned.
|
103
103
|
#
|
104
|
-
# The "style" attribute is converted as best can be to a text representation with a trailing
|
104
|
+
# The "style" attribute is converted as best can be to a text representation with a trailing semicolon.
|
105
105
|
#
|
106
106
|
# The following are deemed to be "boolean" attributes, and will return either "true" or "false":
|
107
107
|
#
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
336
|
+
alias first find_element
|
337
337
|
|
338
338
|
#
|
339
339
|
# element.all(class: 'bar')
|
340
340
|
#
|
341
341
|
|
342
|
-
|
342
|
+
alias all find_elements
|
343
343
|
|
344
344
|
#
|
345
345
|
# element['class'] or element[:class] #=> "someclass"
|
346
346
|
#
|
347
|
-
|
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
|
@@ -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,
|
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,
|
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:,
|
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)
|