selenium-webdriver 4.4.0 → 4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +98 -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/filter_by.rb +40 -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 +143 -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 +3 -2
- 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 +39 -26
- 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/{commands.rb → bridge/commands.rb} +0 -2
- data/lib/selenium/webdriver/remote/bridge.rb +9 -15
- data/lib/selenium/webdriver/remote/capabilities.rb +34 -12
- 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/remote.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 +31 -74
- 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,42 @@
|
|
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 Chromium
|
23
|
+
class Service < WebDriver::Service
|
24
|
+
protected
|
25
|
+
|
26
|
+
def extract_service_args(driver_opts)
|
27
|
+
driver_args = super
|
28
|
+
driver_opts = driver_opts.dup
|
29
|
+
driver_args << "--log-path=#{driver_opts.delete(:log_path)}" if driver_opts.key?(:log_path)
|
30
|
+
driver_args << "--url-base=#{driver_opts.delete(:url_base)}" if driver_opts.key?(:url_base)
|
31
|
+
driver_args << "--port-server=#{driver_opts.delete(:port_server)}" if driver_opts.key?(:port_server)
|
32
|
+
if driver_opts.key?(:whitelisted_ips)
|
33
|
+
driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}"
|
34
|
+
end
|
35
|
+
driver_args << '--verbose' if driver_opts.key?(:verbose)
|
36
|
+
driver_args << '--silent' if driver_opts.key?(:silent)
|
37
|
+
driver_args
|
38
|
+
end
|
39
|
+
end # Service
|
40
|
+
end # Chromium
|
41
|
+
end # WebDriver
|
42
|
+
end # Selenium
|
@@ -0,0 +1,32 @@
|
|
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
|
+
require 'net/http'
|
21
|
+
|
22
|
+
module Selenium
|
23
|
+
module WebDriver
|
24
|
+
module Chromium
|
25
|
+
autoload :Features, 'selenium/webdriver/chromium/features'
|
26
|
+
autoload :Driver, 'selenium/webdriver/chromium/driver'
|
27
|
+
autoload :Profile, 'selenium/webdriver/chromium/profile'
|
28
|
+
autoload :Options, 'selenium/webdriver/chromium/options'
|
29
|
+
autoload :Service, 'selenium/webdriver/chromium/service'
|
30
|
+
end # Chromium
|
31
|
+
end # WebDriver
|
32
|
+
end # Selenium
|
@@ -42,30 +42,13 @@ module Selenium
|
|
42
42
|
# @return [ActionBuilder] A self reference.
|
43
43
|
#
|
44
44
|
|
45
|
-
def initialize(bridge,
|
46
|
-
devices: [], async: false, duration: 250)
|
45
|
+
def initialize(bridge, devices: [], async: false, duration: 250)
|
47
46
|
@bridge = bridge
|
48
47
|
@duration = duration
|
49
|
-
|
50
|
-
@async = if deprecated_async.nil?
|
51
|
-
async
|
52
|
-
else
|
53
|
-
WebDriver.logger.deprecate('initializing ActionBuilder with async parameter',
|
54
|
-
':async keyword',
|
55
|
-
id: :action_async)
|
56
|
-
deprecated_async
|
57
|
-
end
|
58
|
-
|
48
|
+
@async = async
|
59
49
|
@devices = []
|
60
|
-
|
61
|
-
|
62
|
-
"devices keyword or, even better, Driver#action",
|
63
|
-
id: :action_devices
|
64
|
-
add_input(deprecated_mouse)
|
65
|
-
add_input(deprecated_keyboard)
|
66
|
-
else
|
67
|
-
Array(devices).each { |device| add_input(device) }
|
68
|
-
end
|
50
|
+
|
51
|
+
Array(devices).each { |device| add_input(device) }
|
69
52
|
end
|
70
53
|
|
71
54
|
#
|
@@ -118,20 +101,6 @@ module Selenium
|
|
118
101
|
add_input(Interactions.wheel(name))
|
119
102
|
end
|
120
103
|
|
121
|
-
#
|
122
|
-
# Retrieves the input device for the given name
|
123
|
-
#
|
124
|
-
# @param [String] name name of the input device
|
125
|
-
# @return [Selenium::WebDriver::Interactions::InputDevice] input device with given name
|
126
|
-
#
|
127
|
-
|
128
|
-
def get_device(name)
|
129
|
-
WebDriver.logger.deprecate('#get_device with name parameter',
|
130
|
-
'#device with :name or :type keyword',
|
131
|
-
id: :get_device)
|
132
|
-
device(name: name)
|
133
|
-
end
|
134
|
-
|
135
104
|
#
|
136
105
|
# Retrieves the input device for the given name or type
|
137
106
|
#
|
@@ -194,11 +163,9 @@ module Selenium
|
|
194
163
|
# @return [ActionBuilder] A self reference.
|
195
164
|
#
|
196
165
|
|
197
|
-
def pause(
|
198
|
-
|
199
|
-
|
200
|
-
device ||= deprecated_device || pointer_input
|
201
|
-
device.create_pause(deprecated_duration || duration)
|
166
|
+
def pause(device: nil, duration: 0)
|
167
|
+
device ||= pointer_input
|
168
|
+
device.create_pause(duration)
|
202
169
|
self
|
203
170
|
end
|
204
171
|
|
@@ -218,13 +185,10 @@ module Selenium
|
|
218
185
|
# @return [ActionBuilder] A self reference.
|
219
186
|
#
|
220
187
|
|
221
|
-
def pauses(
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
number ||= deprecated_number || 2
|
226
|
-
device ||= deprecated_device || pointer_input
|
227
|
-
duration ||= deprecated_duration || 0
|
188
|
+
def pauses(device: nil, number: nil, duration: 0)
|
189
|
+
number ||= 2
|
190
|
+
device ||= pointer_input
|
191
|
+
duration ||= 0
|
228
192
|
|
229
193
|
number.times { device.create_pause(duration) }
|
230
194
|
self
|
@@ -294,7 +258,6 @@ module Selenium
|
|
294
258
|
':device, :duration, :number keywords',
|
295
259
|
id: method
|
296
260
|
end
|
297
|
-
|
298
261
|
end # ActionBuilder
|
299
262
|
end # WebDriver
|
300
263
|
end # Selenium
|
@@ -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,8 +69,8 @@ module Selenium
|
|
69
69
|
#
|
70
70
|
|
71
71
|
def initialize(bridge: nil, listener: nil, **opts)
|
72
|
-
@service = nil
|
73
72
|
@devtools = nil
|
73
|
+
@bidi = nil
|
74
74
|
bridge ||= create_bridge(**opts)
|
75
75
|
add_extensions(bridge.browser)
|
76
76
|
@bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
|
@@ -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,8 +172,9 @@ module Selenium
|
|
180
172
|
def quit
|
181
173
|
bridge.quit
|
182
174
|
ensure
|
183
|
-
@
|
175
|
+
@service_manager&.stop
|
184
176
|
@devtools&.close
|
177
|
+
@bidi&.close
|
185
178
|
end
|
186
179
|
|
187
180
|
#
|
@@ -189,7 +182,10 @@ module Selenium
|
|
189
182
|
#
|
190
183
|
|
191
184
|
def close
|
192
|
-
|
185
|
+
# If no top-level browsing contexts are open after calling close,
|
186
|
+
# it indicates that the WebDriver session is closed.
|
187
|
+
# If the WebDriver session is closed, the BiDi session also needs to be closed.
|
188
|
+
bridge.close.tap { |handles| @bidi&.close if handles&.empty? }
|
193
189
|
end
|
194
190
|
|
195
191
|
#
|
@@ -263,19 +259,19 @@ module Selenium
|
|
263
259
|
# driver.first(id: 'foo')
|
264
260
|
#
|
265
261
|
|
266
|
-
|
262
|
+
alias first find_element
|
267
263
|
|
268
264
|
#
|
269
265
|
# driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
|
270
266
|
#
|
271
267
|
|
272
|
-
|
268
|
+
alias all find_elements
|
273
269
|
|
274
270
|
#
|
275
271
|
# driver.script('function() { ... };')
|
276
272
|
#
|
277
273
|
|
278
|
-
|
274
|
+
alias script execute_script
|
279
275
|
|
280
276
|
# Get the first element matching the given selector. If given a
|
281
277
|
# String or Symbol, it will be used as the id of the element.
|
@@ -316,30 +312,45 @@ module Selenium
|
|
316
312
|
|
317
313
|
attr_reader :bridge
|
318
314
|
|
319
|
-
def create_bridge(
|
320
|
-
Remote::Bridge.new(http_client: http_client,
|
321
|
-
|
322
|
-
|
323
|
-
|
315
|
+
def create_bridge(caps:, url:, http_client: nil)
|
316
|
+
Remote::Bridge.new(http_client: http_client, url: url).tap do |bridge|
|
317
|
+
bridge.create_session(caps)
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
def process_options(options, capabilities)
|
322
|
+
if options && capabilities
|
323
|
+
msg = "Don't use both :options and :capabilities when initializing #{self.class}, prefer :options"
|
324
|
+
raise ArgumentError, msg
|
325
|
+
end
|
326
|
+
|
327
|
+
options ? options.as_json : deprecate_capabilities(capabilities)
|
328
|
+
end
|
329
|
+
|
330
|
+
def deprecate_capabilities(capabilities)
|
331
|
+
unless is_a?(Remote::Driver)
|
332
|
+
WebDriver.logger.deprecate("The :capabilities parameter for #{self.class}",
|
333
|
+
":options argument with an instance of #{self.class}",
|
334
|
+
id: :capabilities)
|
324
335
|
end
|
336
|
+
generate_capabilities(capabilities)
|
325
337
|
end
|
326
338
|
|
327
339
|
def generate_capabilities(capabilities)
|
328
340
|
Array(capabilities).map { |cap|
|
329
341
|
if cap.is_a? Symbol
|
330
|
-
cap =
|
342
|
+
cap = WebDriver::Options.send(cap)
|
331
343
|
elsif !cap.respond_to? :as_json
|
332
344
|
msg = ":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not"
|
333
345
|
raise ArgumentError, msg
|
334
346
|
end
|
335
347
|
cap.as_json
|
336
|
-
}.inject(:merge)
|
348
|
+
}.inject(:merge)
|
337
349
|
end
|
338
350
|
|
339
351
|
def service_url(service)
|
340
|
-
|
341
|
-
@
|
342
|
-
@service.uri
|
352
|
+
@service_manager = service.launch
|
353
|
+
@service_manager.uri
|
343
354
|
end
|
344
355
|
|
345
356
|
def screenshot
|
@@ -349,11 +360,13 @@ module Selenium
|
|
349
360
|
def add_extensions(browser)
|
350
361
|
extensions = case browser
|
351
362
|
when :chrome, :msedge
|
352
|
-
|
363
|
+
Chromium::Driver::EXTENSIONS
|
353
364
|
when :firefox
|
354
365
|
Firefox::Driver::EXTENSIONS
|
355
366
|
when :safari, :safari_technology_preview
|
356
367
|
Safari::Driver::EXTENSIONS
|
368
|
+
when :ie, :internet_explorer
|
369
|
+
IE::Driver::EXTENSIONS
|
357
370
|
else
|
358
371
|
[]
|
359
372
|
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
|