selenium-webdriver 4.0.0.beta1 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +89 -0
- data/Gemfile +3 -1
- data/NOTICE +2 -0
- data/lib/selenium/webdriver/atoms/findElements.js +77 -78
- data/lib/selenium/webdriver/atoms/getAttribute.js +64 -68
- data/lib/selenium/webdriver/atoms/isDisplayed.js +27 -27
- data/lib/selenium/webdriver/atoms/mutationListener.js +17 -0
- data/lib/selenium/webdriver/chrome/driver.rb +21 -18
- data/lib/selenium/webdriver/chrome/options.rb +1 -1
- data/lib/selenium/webdriver/chrome/profile.rb +5 -2
- data/lib/selenium/webdriver/chrome/service.rb +3 -1
- data/lib/selenium/webdriver/chrome.rb +1 -1
- data/lib/selenium/webdriver/common/driver.rb +23 -4
- data/lib/selenium/webdriver/{devtools/v87/schema.rb → common/driver_extensions/full_page_screenshot.rb} +16 -21
- data/lib/selenium/webdriver/{edge/bridge.rb → common/driver_extensions/has_cdp.rb} +12 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +6 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -6
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +67 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
- data/lib/selenium/webdriver/common/driver_extensions/prints_page.rb +28 -1
- data/lib/selenium/webdriver/common/element.rb +75 -17
- data/lib/selenium/webdriver/common/error.rb +12 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +4 -1
- data/lib/selenium/webdriver/common/logger.rb +5 -2
- data/lib/selenium/webdriver/common/options.rb +62 -17
- data/lib/selenium/webdriver/common/proxy.rb +6 -3
- data/lib/selenium/webdriver/common/search_context.rb +4 -1
- data/lib/selenium/webdriver/common/service.rb +1 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +19 -30
- data/lib/selenium/webdriver/common/takes_screenshot.rb +9 -6
- data/lib/selenium/webdriver/common.rb +5 -0
- data/lib/selenium/webdriver/{firefox/bridge.rb → devtools/pinned_script.rb} +28 -16
- data/lib/selenium/webdriver/devtools/{v87/console.rb → request.rb} +32 -34
- data/lib/selenium/webdriver/devtools.rb +35 -25
- data/lib/selenium/webdriver/edge/driver.rb +2 -6
- data/lib/selenium/webdriver/edge/options.rb +0 -0
- data/lib/selenium/webdriver/edge/profile.rb +0 -0
- data/lib/selenium/webdriver/edge.rb +1 -1
- data/lib/selenium/webdriver/firefox/driver.rb +14 -13
- data/lib/selenium/webdriver/firefox/features.rb +6 -1
- data/lib/selenium/webdriver/firefox.rb +5 -1
- data/lib/selenium/webdriver/ie/driver.rb +1 -1
- data/lib/selenium/webdriver/ie/options.rb +3 -1
- data/lib/selenium/webdriver/ie/service.rb +4 -2
- data/lib/selenium/webdriver/remote/bridge.rb +65 -14
- data/lib/selenium/webdriver/remote/capabilities.rb +105 -52
- data/lib/selenium/webdriver/remote/commands.rb +5 -0
- data/lib/selenium/webdriver/remote/driver.rb +8 -4
- data/lib/selenium/webdriver/remote/http/common.rb +0 -5
- data/lib/selenium/webdriver/remote/http/default.rb +5 -3
- data/lib/selenium/webdriver/remote.rb +1 -1
- data/lib/selenium/webdriver/safari/driver.rb +3 -7
- data/lib/selenium/webdriver/safari.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/event_firing_bridge.rb +2 -2
- data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
- data/lib/selenium/webdriver/{devtools/v87/system_info.rb → support/guards/guard_condition.rb} +24 -24
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/select.rb +2 -2
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +0 -1
- data/selenium-webdriver.gemspec +21 -8
- metadata +62 -233
- data/lib/selenium/webdriver/chrome/bridge.rb +0 -66
- data/lib/selenium/webdriver/devtools/v85/accessibility.rb +0 -64
- data/lib/selenium/webdriver/devtools/v85/animation.rb +0 -100
- data/lib/selenium/webdriver/devtools/v85/application_cache.rb +0 -66
- data/lib/selenium/webdriver/devtools/v85/audits.rb +0 -63
- data/lib/selenium/webdriver/devtools/v85/background_service.rb +0 -69
- data/lib/selenium/webdriver/devtools/v85/browser.rb +0 -125
- data/lib/selenium/webdriver/devtools/v85/cache_storage.rb +0 -75
- data/lib/selenium/webdriver/devtools/v85/cast.rb +0 -72
- data/lib/selenium/webdriver/devtools/v85/console.rb +0 -59
- data/lib/selenium/webdriver/devtools/v85/css.rb +0 -167
- data/lib/selenium/webdriver/devtools/v85/database.rb +0 -66
- data/lib/selenium/webdriver/devtools/v85/debugger.rb +0 -231
- data/lib/selenium/webdriver/devtools/v85/device_orientation.rb +0 -55
- data/lib/selenium/webdriver/devtools/v85/dom.rb +0 -322
- data/lib/selenium/webdriver/devtools/v85/dom_debugger.rb +0 -95
- data/lib/selenium/webdriver/devtools/v85/dom_snapshot.rb +0 -67
- data/lib/selenium/webdriver/devtools/v85/dom_storage.rb +0 -81
- data/lib/selenium/webdriver/devtools/v85/emulation.rb +0 -182
- data/lib/selenium/webdriver/devtools/v85/fetch.rb +0 -99
- data/lib/selenium/webdriver/devtools/v85/headless_experimental.rb +0 -63
- data/lib/selenium/webdriver/devtools/v85/heap_profiler.rb +0 -109
- data/lib/selenium/webdriver/devtools/v85/indexed_db.rb +0 -102
- data/lib/selenium/webdriver/devtools/v85/input.rb +0 -143
- data/lib/selenium/webdriver/devtools/v85/inspector.rb +0 -57
- data/lib/selenium/webdriver/devtools/v85/io.rb +0 -61
- data/lib/selenium/webdriver/devtools/v85/layer_tree.rb +0 -97
- data/lib/selenium/webdriver/devtools/v85/log.rb +0 -68
- data/lib/selenium/webdriver/devtools/v85/media.rb +0 -59
- data/lib/selenium/webdriver/devtools/v85/memory.rb +0 -88
- data/lib/selenium/webdriver/devtools/v85/network.rb +0 -230
- data/lib/selenium/webdriver/devtools/v85/overlay.rb +0 -160
- data/lib/selenium/webdriver/devtools/v85/page.rb +0 -376
- data/lib/selenium/webdriver/devtools/v85/performance.rb +0 -65
- data/lib/selenium/webdriver/devtools/v85/profiler.rb +0 -113
- data/lib/selenium/webdriver/devtools/v85/runtime.rb +0 -196
- data/lib/selenium/webdriver/devtools/v85/schema.rb +0 -48
- data/lib/selenium/webdriver/devtools/v85/security.rb +0 -73
- data/lib/selenium/webdriver/devtools/v85/service_worker.rb +0 -118
- data/lib/selenium/webdriver/devtools/v85/storage.rb +0 -97
- data/lib/selenium/webdriver/devtools/v85/system_info.rb +0 -52
- data/lib/selenium/webdriver/devtools/v85/target.rb +0 -145
- data/lib/selenium/webdriver/devtools/v85/tethering.rb +0 -57
- data/lib/selenium/webdriver/devtools/v85/tracing.rb +0 -78
- data/lib/selenium/webdriver/devtools/v85/web_audio.rb +0 -72
- data/lib/selenium/webdriver/devtools/v85/web_authn.rb +0 -96
- data/lib/selenium/webdriver/devtools/v86/accessibility.rb +0 -64
- data/lib/selenium/webdriver/devtools/v86/animation.rb +0 -100
- data/lib/selenium/webdriver/devtools/v86/application_cache.rb +0 -66
- data/lib/selenium/webdriver/devtools/v86/audits.rb +0 -63
- data/lib/selenium/webdriver/devtools/v86/background_service.rb +0 -69
- data/lib/selenium/webdriver/devtools/v86/browser.rb +0 -125
- data/lib/selenium/webdriver/devtools/v86/cache_storage.rb +0 -75
- data/lib/selenium/webdriver/devtools/v86/cast.rb +0 -72
- data/lib/selenium/webdriver/devtools/v86/console.rb +0 -59
- data/lib/selenium/webdriver/devtools/v86/css.rb +0 -181
- data/lib/selenium/webdriver/devtools/v86/database.rb +0 -66
- data/lib/selenium/webdriver/devtools/v86/debugger.rb +0 -233
- data/lib/selenium/webdriver/devtools/v86/device_orientation.rb +0 -55
- data/lib/selenium/webdriver/devtools/v86/dom.rb +0 -329
- data/lib/selenium/webdriver/devtools/v86/dom_debugger.rb +0 -95
- data/lib/selenium/webdriver/devtools/v86/dom_snapshot.rb +0 -67
- data/lib/selenium/webdriver/devtools/v86/dom_storage.rb +0 -81
- data/lib/selenium/webdriver/devtools/v86/emulation.rb +0 -193
- data/lib/selenium/webdriver/devtools/v86/fetch.rb +0 -99
- data/lib/selenium/webdriver/devtools/v86/headless_experimental.rb +0 -63
- data/lib/selenium/webdriver/devtools/v86/heap_profiler.rb +0 -109
- data/lib/selenium/webdriver/devtools/v86/indexed_db.rb +0 -102
- data/lib/selenium/webdriver/devtools/v86/input.rb +0 -143
- data/lib/selenium/webdriver/devtools/v86/inspector.rb +0 -57
- data/lib/selenium/webdriver/devtools/v86/io.rb +0 -61
- data/lib/selenium/webdriver/devtools/v86/layer_tree.rb +0 -97
- data/lib/selenium/webdriver/devtools/v86/log.rb +0 -68
- data/lib/selenium/webdriver/devtools/v86/media.rb +0 -59
- data/lib/selenium/webdriver/devtools/v86/memory.rb +0 -88
- data/lib/selenium/webdriver/devtools/v86/network.rb +0 -235
- data/lib/selenium/webdriver/devtools/v86/overlay.rb +0 -183
- data/lib/selenium/webdriver/devtools/v86/page.rb +0 -376
- data/lib/selenium/webdriver/devtools/v86/performance.rb +0 -65
- data/lib/selenium/webdriver/devtools/v86/profiler.rb +0 -113
- data/lib/selenium/webdriver/devtools/v86/runtime.rb +0 -196
- data/lib/selenium/webdriver/devtools/v86/schema.rb +0 -48
- data/lib/selenium/webdriver/devtools/v86/security.rb +0 -73
- data/lib/selenium/webdriver/devtools/v86/service_worker.rb +0 -118
- data/lib/selenium/webdriver/devtools/v86/storage.rb +0 -97
- data/lib/selenium/webdriver/devtools/v86/system_info.rb +0 -52
- data/lib/selenium/webdriver/devtools/v86/target.rb +0 -145
- data/lib/selenium/webdriver/devtools/v86/tethering.rb +0 -57
- data/lib/selenium/webdriver/devtools/v86/tracing.rb +0 -78
- data/lib/selenium/webdriver/devtools/v86/web_audio.rb +0 -72
- data/lib/selenium/webdriver/devtools/v86/web_authn.rb +0 -102
- data/lib/selenium/webdriver/devtools/v87/accessibility.rb +0 -73
- data/lib/selenium/webdriver/devtools/v87/animation.rb +0 -100
- data/lib/selenium/webdriver/devtools/v87/application_cache.rb +0 -66
- data/lib/selenium/webdriver/devtools/v87/audits.rb +0 -63
- data/lib/selenium/webdriver/devtools/v87/background_service.rb +0 -69
- data/lib/selenium/webdriver/devtools/v87/browser.rb +0 -125
- data/lib/selenium/webdriver/devtools/v87/cache_storage.rb +0 -75
- data/lib/selenium/webdriver/devtools/v87/cast.rb +0 -72
- data/lib/selenium/webdriver/devtools/v87/css.rb +0 -181
- data/lib/selenium/webdriver/devtools/v87/database.rb +0 -66
- data/lib/selenium/webdriver/devtools/v87/debugger.rb +0 -233
- data/lib/selenium/webdriver/devtools/v87/device_orientation.rb +0 -55
- data/lib/selenium/webdriver/devtools/v87/dom.rb +0 -329
- data/lib/selenium/webdriver/devtools/v87/dom_debugger.rb +0 -95
- data/lib/selenium/webdriver/devtools/v87/dom_snapshot.rb +0 -67
- data/lib/selenium/webdriver/devtools/v87/dom_storage.rb +0 -81
- data/lib/selenium/webdriver/devtools/v87/emulation.rb +0 -193
- data/lib/selenium/webdriver/devtools/v87/fetch.rb +0 -99
- data/lib/selenium/webdriver/devtools/v87/headless_experimental.rb +0 -63
- data/lib/selenium/webdriver/devtools/v87/heap_profiler.rb +0 -109
- data/lib/selenium/webdriver/devtools/v87/indexed_db.rb +0 -102
- data/lib/selenium/webdriver/devtools/v87/input.rb +0 -143
- data/lib/selenium/webdriver/devtools/v87/inspector.rb +0 -57
- data/lib/selenium/webdriver/devtools/v87/io.rb +0 -61
- data/lib/selenium/webdriver/devtools/v87/layer_tree.rb +0 -97
- data/lib/selenium/webdriver/devtools/v87/log.rb +0 -68
- data/lib/selenium/webdriver/devtools/v87/media.rb +0 -59
- data/lib/selenium/webdriver/devtools/v87/memory.rb +0 -88
- data/lib/selenium/webdriver/devtools/v87/network.rb +0 -247
- data/lib/selenium/webdriver/devtools/v87/overlay.rb +0 -183
- data/lib/selenium/webdriver/devtools/v87/page.rb +0 -376
- data/lib/selenium/webdriver/devtools/v87/performance.rb +0 -65
- data/lib/selenium/webdriver/devtools/v87/profiler.rb +0 -125
- data/lib/selenium/webdriver/devtools/v87/runtime.rb +0 -196
- data/lib/selenium/webdriver/devtools/v87/security.rb +0 -73
- data/lib/selenium/webdriver/devtools/v87/service_worker.rb +0 -118
- data/lib/selenium/webdriver/devtools/v87/storage.rb +0 -97
- data/lib/selenium/webdriver/devtools/v87/target.rb +0 -145
- data/lib/selenium/webdriver/devtools/v87/tethering.rb +0 -57
- data/lib/selenium/webdriver/devtools/v87/tracing.rb +0 -78
- data/lib/selenium/webdriver/devtools/v87/web_audio.rb +0 -72
- data/lib/selenium/webdriver/devtools/v87/web_authn.rb +0 -102
- data/lib/selenium/webdriver/devtools/v88/accessibility.rb +0 -73
- data/lib/selenium/webdriver/devtools/v88/animation.rb +0 -100
- data/lib/selenium/webdriver/devtools/v88/application_cache.rb +0 -66
- data/lib/selenium/webdriver/devtools/v88/audits.rb +0 -63
- data/lib/selenium/webdriver/devtools/v88/background_service.rb +0 -69
- data/lib/selenium/webdriver/devtools/v88/browser.rb +0 -130
- data/lib/selenium/webdriver/devtools/v88/cache_storage.rb +0 -75
- data/lib/selenium/webdriver/devtools/v88/cast.rb +0 -72
- data/lib/selenium/webdriver/devtools/v88/console.rb +0 -59
- data/lib/selenium/webdriver/devtools/v88/css.rb +0 -181
- data/lib/selenium/webdriver/devtools/v88/database.rb +0 -66
- data/lib/selenium/webdriver/devtools/v88/debugger.rb +0 -233
- data/lib/selenium/webdriver/devtools/v88/device_orientation.rb +0 -55
- data/lib/selenium/webdriver/devtools/v88/dom.rb +0 -329
- data/lib/selenium/webdriver/devtools/v88/dom_debugger.rb +0 -95
- data/lib/selenium/webdriver/devtools/v88/dom_snapshot.rb +0 -67
- data/lib/selenium/webdriver/devtools/v88/dom_storage.rb +0 -81
- data/lib/selenium/webdriver/devtools/v88/emulation.rb +0 -198
- data/lib/selenium/webdriver/devtools/v88/fetch.rb +0 -99
- data/lib/selenium/webdriver/devtools/v88/headless_experimental.rb +0 -63
- data/lib/selenium/webdriver/devtools/v88/heap_profiler.rb +0 -109
- data/lib/selenium/webdriver/devtools/v88/indexed_db.rb +0 -102
- data/lib/selenium/webdriver/devtools/v88/input.rb +0 -148
- data/lib/selenium/webdriver/devtools/v88/inspector.rb +0 -57
- data/lib/selenium/webdriver/devtools/v88/io.rb +0 -61
- data/lib/selenium/webdriver/devtools/v88/layer_tree.rb +0 -97
- data/lib/selenium/webdriver/devtools/v88/log.rb +0 -68
- data/lib/selenium/webdriver/devtools/v88/media.rb +0 -59
- data/lib/selenium/webdriver/devtools/v88/memory.rb +0 -88
- data/lib/selenium/webdriver/devtools/v88/network.rb +0 -247
- data/lib/selenium/webdriver/devtools/v88/overlay.rb +0 -183
- data/lib/selenium/webdriver/devtools/v88/page.rb +0 -376
- data/lib/selenium/webdriver/devtools/v88/performance.rb +0 -65
- data/lib/selenium/webdriver/devtools/v88/profiler.rb +0 -125
- data/lib/selenium/webdriver/devtools/v88/runtime.rb +0 -197
- data/lib/selenium/webdriver/devtools/v88/schema.rb +0 -48
- data/lib/selenium/webdriver/devtools/v88/security.rb +0 -73
- data/lib/selenium/webdriver/devtools/v88/service_worker.rb +0 -118
- data/lib/selenium/webdriver/devtools/v88/storage.rb +0 -103
- data/lib/selenium/webdriver/devtools/v88/system_info.rb +0 -52
- data/lib/selenium/webdriver/devtools/v88/target.rb +0 -145
- data/lib/selenium/webdriver/devtools/v88/tethering.rb +0 -57
- data/lib/selenium/webdriver/devtools/v88/tracing.rb +0 -79
- data/lib/selenium/webdriver/devtools/v88/web_audio.rb +0 -72
- data/lib/selenium/webdriver/devtools/v88/web_authn.rb +0 -102
- data/lib/selenium/webdriver/safari/bridge.rb +0 -51
- data/selenium_server_deploy.jar +0 -0
@@ -1,3 +1,20 @@
|
|
1
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
2
|
+
// or more contributor license agreements. See the NOTICE file
|
3
|
+
// distributed with this work for additional information
|
4
|
+
// regarding copyright ownership. The SFC licenses this file
|
5
|
+
// to you under the Apache License, Version 2.0 (the
|
6
|
+
// "License"); you may not use this file except in compliance
|
7
|
+
// with the License. You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing,
|
12
|
+
// software distributed under the License is distributed on an
|
13
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
// KIND, either express or implied. See the License for the
|
15
|
+
// specific language governing permissions and limitations
|
16
|
+
// under the License.
|
17
|
+
|
1
18
|
(function () {
|
2
19
|
const observer = new MutationObserver((mutations) => {
|
3
20
|
for (const mutation of mutations) {
|
@@ -27,37 +27,40 @@ module Selenium
|
|
27
27
|
#
|
28
28
|
|
29
29
|
class Driver < WebDriver::Driver
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
EXTENSIONS = [DriverExtensions::HasCDP,
|
31
|
+
DriverExtensions::HasNetworkConditions,
|
32
|
+
DriverExtensions::HasNetworkInterception,
|
33
|
+
DriverExtensions::HasWebStorage,
|
34
|
+
DriverExtensions::HasLocation,
|
35
|
+
DriverExtensions::DownloadsFiles,
|
36
|
+
DriverExtensions::HasDevTools,
|
37
|
+
DriverExtensions::HasAuthentication,
|
38
|
+
DriverExtensions::HasLogs,
|
39
|
+
DriverExtensions::HasLogEvents,
|
40
|
+
DriverExtensions::HasPinnedScripts,
|
41
|
+
DriverExtensions::PrintsPage].freeze
|
39
42
|
|
40
43
|
def browser
|
41
44
|
:chrome
|
42
45
|
end
|
43
46
|
|
44
|
-
|
45
|
-
Bridge
|
46
|
-
end
|
47
|
+
private
|
47
48
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
49
|
+
def devtools_url
|
50
|
+
uri = URI(devtools_address)
|
51
|
+
response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
|
51
52
|
|
52
|
-
|
53
|
+
JSON.parse(response)['webSocketDebuggerUrl']
|
54
|
+
end
|
53
55
|
|
54
56
|
def devtools_version
|
55
57
|
Integer(capabilities.browser_version.split('.').first)
|
56
58
|
end
|
57
59
|
|
58
|
-
def
|
59
|
-
capabilities['goog:chromeOptions']['debuggerAddress']
|
60
|
+
def devtools_address
|
61
|
+
"http://#{capabilities['goog:chromeOptions']['debuggerAddress']}"
|
60
62
|
end
|
63
|
+
|
61
64
|
end # Driver
|
62
65
|
end # Chrome
|
63
66
|
end # WebDriver
|
@@ -27,12 +27,11 @@ module Selenium
|
|
27
27
|
class Profile
|
28
28
|
include ProfileHelper
|
29
29
|
|
30
|
-
attr_reader :directory
|
31
|
-
|
32
30
|
def initialize(model = nil)
|
33
31
|
@model = verify_model(model)
|
34
32
|
@extensions = []
|
35
33
|
@encoded_extensions = []
|
34
|
+
@directory = nil
|
36
35
|
end
|
37
36
|
|
38
37
|
def add_extension(path)
|
@@ -45,6 +44,10 @@ module Selenium
|
|
45
44
|
@encoded_extensions << encoded
|
46
45
|
end
|
47
46
|
|
47
|
+
def directory
|
48
|
+
@directory || layout_on_disk
|
49
|
+
end
|
50
|
+
|
48
51
|
#
|
49
52
|
# Set a preference in the profile.
|
50
53
|
#
|
@@ -39,7 +39,9 @@ module Selenium
|
|
39
39
|
driver_args << "--log-path=#{driver_opts.delete(:log_path)}" if driver_opts.key?(:log_path)
|
40
40
|
driver_args << "--url-base=#{driver_opts.delete(:url_base)}" if driver_opts.key?(:url_base)
|
41
41
|
driver_args << "--port-server=#{driver_opts.delete(:port_server)}" if driver_opts.key?(:port_server)
|
42
|
-
|
42
|
+
if driver_opts.key?(:whitelisted_ips)
|
43
|
+
driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}"
|
44
|
+
end
|
43
45
|
driver_args << "--verbose" if driver_opts.key?(:verbose)
|
44
46
|
driver_args << "--silent" if driver_opts.key?(:silent)
|
45
47
|
driver_args
|
@@ -22,7 +22,7 @@ require 'net/http'
|
|
22
22
|
module Selenium
|
23
23
|
module WebDriver
|
24
24
|
module Chrome
|
25
|
-
autoload :
|
25
|
+
autoload :Features, 'selenium/webdriver/chrome/features'
|
26
26
|
autoload :Driver, 'selenium/webdriver/chrome/driver'
|
27
27
|
autoload :Profile, 'selenium/webdriver/chrome/profile'
|
28
28
|
autoload :Options, 'selenium/webdriver/chrome/options'
|
@@ -71,11 +71,13 @@ module Selenium
|
|
71
71
|
def initialize(bridge: nil, listener: nil, **opts)
|
72
72
|
@service = nil
|
73
73
|
bridge ||= create_bridge(**opts)
|
74
|
+
add_extensions(bridge.browser)
|
74
75
|
@bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
|
75
76
|
end
|
76
77
|
|
77
78
|
def inspect
|
78
|
-
format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2,
|
79
|
+
format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2,
|
80
|
+
browser: bridge.browser.inspect
|
79
81
|
end
|
80
82
|
|
81
83
|
#
|
@@ -295,7 +297,9 @@ module Selenium
|
|
295
297
|
# @see SearchContext
|
296
298
|
#
|
297
299
|
|
298
|
-
def ref
|
300
|
+
def ref
|
301
|
+
[:driver, nil]
|
302
|
+
end
|
299
303
|
|
300
304
|
private
|
301
305
|
|
@@ -329,7 +333,7 @@ module Selenium
|
|
329
333
|
bridge_opts = {http_client: opts.delete(:http_client), url: opts.delete(:url)}
|
330
334
|
raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
|
331
335
|
|
332
|
-
bridge =
|
336
|
+
bridge = Remote::Bridge.new(**bridge_opts)
|
333
337
|
|
334
338
|
bridge.create_session(capabilities)
|
335
339
|
bridge
|
@@ -340,8 +344,9 @@ module Selenium
|
|
340
344
|
if cap.is_a? Symbol
|
341
345
|
cap = Remote::Capabilities.send(cap)
|
342
346
|
elsif cap.is_a? Hash
|
347
|
+
new_message = 'Capabilities instance initialized with the Hash, or build values with Options class'
|
343
348
|
WebDriver.logger.deprecate("passing a Hash value to :capabilities",
|
344
|
-
|
349
|
+
new_message,
|
345
350
|
id: :capabilities_hash)
|
346
351
|
cap = Remote::Capabilities.new(cap)
|
347
352
|
elsif !cap.respond_to? :as_json
|
@@ -371,6 +376,20 @@ module Selenium
|
|
371
376
|
def screenshot
|
372
377
|
bridge.screenshot
|
373
378
|
end
|
379
|
+
|
380
|
+
def add_extensions(browser)
|
381
|
+
extensions = case browser
|
382
|
+
when :chrome, :msedge
|
383
|
+
Chrome::Driver::EXTENSIONS
|
384
|
+
when :firefox
|
385
|
+
Firefox::Driver::EXTENSIONS
|
386
|
+
when :safari, :safari_technology_preview
|
387
|
+
Safari::Driver::EXTENSIONS
|
388
|
+
else
|
389
|
+
[]
|
390
|
+
end
|
391
|
+
extensions.each { |extension| extend extension }
|
392
|
+
end
|
374
393
|
end # Driver
|
375
394
|
end # WebDriver
|
376
395
|
end # Selenium
|
@@ -17,32 +17,27 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
# This file is automatically generated. Any changes will be lost!
|
21
20
|
module Selenium
|
22
21
|
module WebDriver
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
+
#
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
def save_full_page_screenshot(path)
|
31
|
+
save_screenshot(path, full_page: true)
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
@devtools = devtools
|
33
|
-
end
|
34
|
+
private
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
36
|
+
def full_screenshot
|
37
|
+
@bridge.full_screenshot
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end # V87
|
45
|
-
end # Schema
|
46
|
-
end # DevTools
|
40
|
+
end # FullPageScreenshot
|
41
|
+
end # DriverExtensions
|
47
42
|
end # WebDriver
|
48
43
|
end # Selenium
|
@@ -17,21 +17,22 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'selenium/webdriver/chrome/bridge'
|
21
|
-
|
22
20
|
module Selenium
|
23
21
|
module WebDriver
|
24
|
-
module
|
25
|
-
|
22
|
+
module DriverExtensions
|
23
|
+
module HasCDP
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
#
|
26
|
+
# Returns network conditions.
|
27
|
+
#
|
28
|
+
# @return [Hash]
|
29
|
+
#
|
30
30
|
|
31
|
-
def
|
32
|
-
|
31
|
+
def execute_cdp(cmd, **params)
|
32
|
+
@bridge.send_command(cmd: cmd, params: params)
|
33
33
|
end
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
end # HasCDP
|
36
|
+
end # DriverExtensions
|
36
37
|
end # WebDriver
|
37
38
|
end # Selenium
|
@@ -29,7 +29,12 @@ module Selenium
|
|
29
29
|
#
|
30
30
|
|
31
31
|
def devtools
|
32
|
-
@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
|
33
38
|
end
|
34
39
|
|
35
40
|
end # HasDevTools
|
@@ -112,8 +112,7 @@ module Selenium
|
|
112
112
|
|
113
113
|
devtools.runtime.add_binding(name: '__webdriver_attribute')
|
114
114
|
execute_script(mutation_listener)
|
115
|
-
|
116
|
-
pinned_scripts[mutation_listener] = script['identifier']
|
115
|
+
devtools.page.add_script_to_evaluate_on_new_document(source: mutation_listener)
|
117
116
|
|
118
117
|
devtools.runtime.on(:binding_called, &method(:log_mutation_event))
|
119
118
|
end
|
@@ -139,10 +138,6 @@ module Selenium
|
|
139
138
|
@mutation_listener ||= read_atom(:mutationListener)
|
140
139
|
end
|
141
140
|
|
142
|
-
def pinned_scripts
|
143
|
-
@pinned_scripts ||= {}
|
144
|
-
end
|
145
|
-
|
146
141
|
end # HasLogEvents
|
147
142
|
end # DriverExtensions
|
148
143
|
end # WebDriver
|
@@ -23,11 +23,13 @@ module Selenium
|
|
23
23
|
module DriverExtensions
|
24
24
|
module HasNetworkConnection
|
25
25
|
def network_connection_type
|
26
|
-
raise Error::UnsupportedOperationError,
|
26
|
+
raise Error::UnsupportedOperationError,
|
27
|
+
'The W3C standard does not currently support getting network connection'
|
27
28
|
end
|
28
29
|
|
29
30
|
def network_connection_type=(*)
|
30
|
-
raise Error::UnsupportedOperationError,
|
31
|
+
raise Error::UnsupportedOperationError,
|
32
|
+
'The W3C standard does not currently support setting network connection'
|
31
33
|
end
|
32
34
|
end # HasNetworkConnection
|
33
35
|
end # DriverExtensions
|
@@ -0,0 +1,67 @@
|
|
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 HasNetworkInterception
|
24
|
+
|
25
|
+
#
|
26
|
+
# Intercepts requests coming from browser allowing
|
27
|
+
# to either pass them through like proxy or provide
|
28
|
+
# a stubbed response instead.
|
29
|
+
#
|
30
|
+
# @example Log requests and pass through
|
31
|
+
# driver.intercept do |request|
|
32
|
+
# puts "#{request.method} #{request.url}"
|
33
|
+
# request.continue
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# @example Stub response for image requests
|
37
|
+
# driver.intercept do |request|
|
38
|
+
# if request.url.match?(/\.png$/)
|
39
|
+
# request.respond(body: File.read('myfile.png'))
|
40
|
+
# else
|
41
|
+
# request.continue
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# @param [#call] block which is called when request is interecepted
|
46
|
+
# @yieldparam [DevTools::Request]
|
47
|
+
#
|
48
|
+
|
49
|
+
def intercept
|
50
|
+
devtools.network.set_cache_disabled(cache_disabled: true)
|
51
|
+
devtools.fetch.on(:request_paused) do |params|
|
52
|
+
request = DevTools::Request.new(
|
53
|
+
devtools: devtools,
|
54
|
+
id: params['requestId'],
|
55
|
+
url: params.dig('request', 'url'),
|
56
|
+
method: params.dig('request', 'method'),
|
57
|
+
headers: params.dig('request', 'headers')
|
58
|
+
)
|
59
|
+
yield request
|
60
|
+
end
|
61
|
+
devtools.fetch.enable
|
62
|
+
end
|
63
|
+
|
64
|
+
end # HasNetworkInterception
|
65
|
+
end # DriverExtensions
|
66
|
+
end # WebDriver
|
67
|
+
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 HasPinnedScripts
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns the list of all pinned scripts.
|
27
|
+
#
|
28
|
+
# @return [Array<DevTools::PinnedScript>]
|
29
|
+
#
|
30
|
+
|
31
|
+
def pinned_scripts
|
32
|
+
@pinned_scripts ||= []
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Pins JavaScript snippet that is available during the whole
|
37
|
+
# session on every page. This allows to store and call
|
38
|
+
# scripts without sending them over the wire every time.
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# script = driver.pin_script('return window.location.href')
|
42
|
+
# driver.execute_script(script)
|
43
|
+
# # navigate to a new page
|
44
|
+
# driver.execute_script(script)
|
45
|
+
#
|
46
|
+
# @param [String] script
|
47
|
+
# @return [DevTools::PinnedScript]
|
48
|
+
#
|
49
|
+
|
50
|
+
def pin_script(script)
|
51
|
+
script = DevTools::PinnedScript.new(script)
|
52
|
+
pinned_scripts << script
|
53
|
+
|
54
|
+
devtools.page.enable
|
55
|
+
devtools.runtime.evaluate(expression: script.callable)
|
56
|
+
response = devtools.page.add_script_to_evaluate_on_new_document(source: script.callable)
|
57
|
+
script.devtools_identifier = response.dig('result', 'identifier')
|
58
|
+
|
59
|
+
script
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Unpins script making it undefined for the subsequent calls.
|
64
|
+
#
|
65
|
+
# @param [DevTools::PinnedScript]
|
66
|
+
#
|
67
|
+
|
68
|
+
def unpin_script(script)
|
69
|
+
devtools.runtime.evaluate(expression: script.remove)
|
70
|
+
devtools.page.remove_script_to_evaluate_on_new_document(identifier: script.devtools_identifier)
|
71
|
+
pinned_scripts.delete(script)
|
72
|
+
end
|
73
|
+
|
74
|
+
end # HasPinnedScripts
|
75
|
+
end # DriverExtensions
|
76
|
+
end # WebDriver
|
77
|
+
end # Selenium
|