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
@@ -65,37 +65,26 @@ module Selenium
|
|
65
65
|
arr << Errno::EALREADY if Platform.wsl?
|
66
66
|
}.freeze
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
81
|
-
sockaddr = Socket.pack_sockaddr_in(@port, addr[0][3])
|
82
|
-
|
83
|
-
begin
|
84
|
-
sock.connect_nonblock sockaddr
|
85
|
-
rescue Errno::EINPROGRESS
|
86
|
-
retry if socket_writable?(sock) && conn_completed?(sock)
|
87
|
-
raise Errno::ECONNREFUSED
|
88
|
-
rescue *CONNECTED_ERRORS
|
89
|
-
# yay!
|
90
|
-
end
|
91
|
-
|
92
|
-
sock.close
|
93
|
-
true
|
94
|
-
rescue *NOT_CONNECTED_ERRORS
|
95
|
-
sock&.close
|
96
|
-
WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
|
97
|
-
false
|
68
|
+
def listening?
|
69
|
+
addr = Socket.getaddrinfo(@host, @port, Socket::AF_INET, Socket::SOCK_STREAM)
|
70
|
+
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
71
|
+
sockaddr = Socket.pack_sockaddr_in(@port, addr[0][3])
|
72
|
+
|
73
|
+
begin
|
74
|
+
sock.connect_nonblock sockaddr
|
75
|
+
rescue Errno::EINPROGRESS
|
76
|
+
retry if socket_writable?(sock) && conn_completed?(sock)
|
77
|
+
raise Errno::ECONNREFUSED
|
78
|
+
rescue *CONNECTED_ERRORS
|
79
|
+
# yay!
|
98
80
|
end
|
81
|
+
|
82
|
+
sock.close
|
83
|
+
true
|
84
|
+
rescue *NOT_CONNECTED_ERRORS
|
85
|
+
sock&.close
|
86
|
+
WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
|
87
|
+
false
|
99
88
|
end
|
100
89
|
|
101
90
|
def socket_writable?(sock)
|
@@ -24,38 +24,41 @@ module Selenium
|
|
24
24
|
#
|
25
25
|
module TakesScreenshot
|
26
26
|
#
|
27
|
-
# Save a PNG screenshot to the given path
|
27
|
+
# Save a PNG screenshot of the viewport to the given path
|
28
28
|
#
|
29
29
|
# @api public
|
30
30
|
#
|
31
31
|
|
32
|
-
def save_screenshot(png_path)
|
32
|
+
def save_screenshot(png_path, full_page: false)
|
33
33
|
extension = File.extname(png_path).downcase
|
34
34
|
if extension != '.png'
|
35
35
|
WebDriver.logger.warn "name used for saved screenshot does not match file type. "\
|
36
36
|
"It should end with .png extension",
|
37
37
|
id: :screenshot
|
38
38
|
end
|
39
|
-
File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
|
39
|
+
File.open(png_path, 'wb') { |f| f << screenshot_as(:png, full_page: full_page) }
|
40
40
|
end
|
41
41
|
|
42
42
|
#
|
43
43
|
# Return a PNG screenshot in the given format as a string
|
44
44
|
#
|
45
45
|
# @param [:base64, :png] format
|
46
|
+
# @param [Boolean] full_page allows taking full page screenshots if supported
|
46
47
|
# @return String screenshot
|
47
48
|
#
|
48
49
|
# @api public
|
49
50
|
|
50
|
-
def screenshot_as(format)
|
51
|
+
def screenshot_as(format, full_page: false)
|
51
52
|
case format
|
52
53
|
when :base64
|
53
|
-
screenshot
|
54
|
+
full_page ? full_screenshot : screenshot
|
54
55
|
when :png
|
55
|
-
|
56
|
+
screenshot_as(:base64, full_page: full_page).unpack1('m')
|
56
57
|
else
|
57
58
|
raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
|
58
59
|
end
|
60
|
+
rescue NameError
|
61
|
+
raise Error::UnsupportedOperationError, "Full Page Screenshots are not supported for #{inspect}"
|
59
62
|
end
|
60
63
|
|
61
64
|
end # TakesScreenshot
|
@@ -57,18 +57,23 @@ require 'selenium/webdriver/common/driver_extensions/has_session_id'
|
|
57
57
|
require 'selenium/webdriver/common/driver_extensions/has_remote_status'
|
58
58
|
require 'selenium/webdriver/common/driver_extensions/has_network_conditions'
|
59
59
|
require 'selenium/webdriver/common/driver_extensions/has_network_connection'
|
60
|
+
require 'selenium/webdriver/common/driver_extensions/has_network_interception'
|
60
61
|
require 'selenium/webdriver/common/driver_extensions/has_permissions'
|
61
62
|
require 'selenium/webdriver/common/driver_extensions/has_debugger'
|
62
63
|
require 'selenium/webdriver/common/driver_extensions/prints_page'
|
63
64
|
require 'selenium/webdriver/common/driver_extensions/uploads_files'
|
65
|
+
require 'selenium/webdriver/common/driver_extensions/full_page_screenshot'
|
64
66
|
require 'selenium/webdriver/common/driver_extensions/has_addons'
|
65
67
|
require 'selenium/webdriver/common/driver_extensions/has_devtools'
|
66
68
|
require 'selenium/webdriver/common/driver_extensions/has_authentication'
|
67
69
|
require 'selenium/webdriver/common/driver_extensions/has_logs'
|
68
70
|
require 'selenium/webdriver/common/driver_extensions/has_log_events'
|
71
|
+
require 'selenium/webdriver/common/driver_extensions/has_pinned_scripts'
|
72
|
+
require 'selenium/webdriver/common/driver_extensions/has_cdp'
|
69
73
|
require 'selenium/webdriver/common/keys'
|
70
74
|
require 'selenium/webdriver/common/profile_helper'
|
71
75
|
require 'selenium/webdriver/common/options'
|
72
76
|
require 'selenium/webdriver/common/takes_screenshot'
|
73
77
|
require 'selenium/webdriver/common/driver'
|
74
78
|
require 'selenium/webdriver/common/element'
|
79
|
+
require 'selenium/webdriver/common/shadow_root'
|
@@ -19,29 +19,41 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
|
-
class
|
22
|
+
class DevTools
|
23
|
+
class PinnedScript
|
24
24
|
|
25
|
-
|
26
|
-
install_addon: [:post, 'session/:session_id/moz/addon/install'],
|
27
|
-
uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
|
28
|
-
}.freeze
|
25
|
+
attr_accessor :key, :devtools_identifier, :script
|
29
26
|
|
30
|
-
def
|
31
|
-
|
27
|
+
def initialize(script)
|
28
|
+
@key = SecureRandom.alphanumeric
|
29
|
+
@script = script
|
32
30
|
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
#
|
33
|
+
# @api private
|
34
|
+
#
|
35
|
+
|
36
|
+
def callable
|
37
|
+
"function __webdriver_#{key}(arguments) { #{script} }"
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
#
|
41
|
+
# @api private
|
42
|
+
#
|
43
|
+
|
44
|
+
def to_json(*)
|
45
|
+
%{"return __webdriver_#{key}(arguments)"}
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# @api private
|
50
|
+
#
|
51
|
+
|
52
|
+
def remove
|
53
|
+
"__webdriver_#{key} = undefined"
|
42
54
|
end
|
43
55
|
|
44
|
-
end #
|
45
|
-
end #
|
56
|
+
end # PinnedScript
|
57
|
+
end # DevTools
|
46
58
|
end # WebDriver
|
47
59
|
end # Selenium
|
@@ -17,43 +17,41 @@
|
|
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
22
|
class DevTools
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end # Console
|
23
|
+
class Request
|
24
|
+
|
25
|
+
attr_reader :url, :method, :headers
|
26
|
+
|
27
|
+
def initialize(devtools:, id:, url:, method:, headers:)
|
28
|
+
@devtools = devtools
|
29
|
+
@id = id
|
30
|
+
@url = url
|
31
|
+
@method = method
|
32
|
+
@headers = headers
|
33
|
+
end
|
34
|
+
|
35
|
+
def continue
|
36
|
+
@devtools.fetch.continue_request(request_id: @id)
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond(code: 200, headers: {}, body: '')
|
40
|
+
@devtools.fetch.fulfill_request(
|
41
|
+
request_id: @id,
|
42
|
+
body: Base64.strict_encode64(body),
|
43
|
+
response_code: code,
|
44
|
+
response_headers: headers.map do |k, v|
|
45
|
+
{name: k, value: v}
|
46
|
+
end
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def inspect
|
51
|
+
%(#<#{self.class.name} @method="#{method}" @url="#{url}")
|
52
|
+
end
|
53
|
+
|
54
|
+
end # Request
|
57
55
|
end # DevTools
|
58
56
|
end # WebDriver
|
59
57
|
end # Selenium
|
@@ -23,19 +23,17 @@ module Selenium
|
|
23
23
|
autoload :ConsoleEvent, 'selenium/webdriver/devtools/console_event'
|
24
24
|
autoload :ExceptionEvent, 'selenium/webdriver/devtools/exception_event'
|
25
25
|
autoload :MutationEvent, 'selenium/webdriver/devtools/mutation_event'
|
26
|
+
autoload :PinnedScript, 'selenium/webdriver/devtools/pinned_script'
|
27
|
+
autoload :Request, 'selenium/webdriver/devtools/request'
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
def initialize(url:, version:)
|
29
|
+
def initialize(url:)
|
30
30
|
@messages = []
|
31
|
-
@
|
31
|
+
@session_id = nil
|
32
|
+
@url = url
|
32
33
|
|
33
|
-
load_devtools_version(version)
|
34
34
|
process_handshake
|
35
35
|
attach_socket_listener
|
36
|
-
|
37
|
-
target.attach_to_target(target_id: page_target['id'])
|
38
|
-
target.set_auto_attach(auto_attach: true, wait_for_debugger_on_start: false)
|
36
|
+
start_session
|
39
37
|
end
|
40
38
|
|
41
39
|
def callbacks
|
@@ -44,7 +42,9 @@ module Selenium
|
|
44
42
|
|
45
43
|
def send_cmd(method, **params)
|
46
44
|
id = next_id
|
47
|
-
data =
|
45
|
+
data = {id: id, method: method, params: params.reject { |_, v| v.nil? }}
|
46
|
+
data[:sessionId] = @session_id if @session_id
|
47
|
+
data = JSON.generate(data)
|
48
48
|
WebDriver.logger.debug "DevTools -> #{data}"
|
49
49
|
|
50
50
|
out_frame = WebSocket::Frame::Outgoing::Client.new(version: ws.version, data: data, type: 'text')
|
@@ -59,16 +59,26 @@ module Selenium
|
|
59
59
|
message
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
def method_missing(method, *_args)
|
63
|
+
desired_class = "Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}"
|
64
|
+
return unless Object.const_defined?(desired_class)
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
require f
|
66
|
+
self.class.class_eval do
|
67
|
+
define_method(method) do
|
68
|
+
Object.const_get(desired_class).new(self)
|
69
|
+
end
|
69
70
|
end
|
71
|
+
|
72
|
+
send(method)
|
73
|
+
end
|
74
|
+
|
75
|
+
def respond_to_missing?(method, *_args)
|
76
|
+
desired_class = "Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}"
|
77
|
+
Object.const_defined?(desired_class)
|
70
78
|
end
|
71
79
|
|
80
|
+
private
|
81
|
+
|
72
82
|
def process_handshake
|
73
83
|
socket.print(ws.to_s)
|
74
84
|
ws << socket.readpartial(1024)
|
@@ -89,7 +99,8 @@ module Selenium
|
|
89
99
|
next unless message['method']
|
90
100
|
|
91
101
|
callbacks[message['method']].each do |callback|
|
92
|
-
|
102
|
+
params = message['params'] # take in current thread!
|
103
|
+
Thread.new { callback.call(params) }
|
93
104
|
end
|
94
105
|
end
|
95
106
|
end
|
@@ -97,6 +108,13 @@ module Selenium
|
|
97
108
|
socket_listener.abort_on_exception = true
|
98
109
|
end
|
99
110
|
|
111
|
+
def start_session
|
112
|
+
targets = target.get_targets.dig('result', 'targetInfos')
|
113
|
+
page_target = targets.find { |target| target['type'] == 'page' }
|
114
|
+
session = target.attach_to_target(target_id: page_target['targetId'], flatten: true)
|
115
|
+
@session_id = session.dig('result', 'sessionId')
|
116
|
+
end
|
117
|
+
|
100
118
|
def incoming_frame
|
101
119
|
@incoming_frame ||= WebSocket::Frame::Incoming::Client.new(version: ws.version)
|
102
120
|
end
|
@@ -110,15 +128,7 @@ module Selenium
|
|
110
128
|
end
|
111
129
|
|
112
130
|
def ws
|
113
|
-
@ws ||= WebSocket::Handshake::Client.new(url:
|
114
|
-
end
|
115
|
-
|
116
|
-
def page_target
|
117
|
-
@page_target ||= begin
|
118
|
-
response = Net::HTTP.get(@uri.hostname, '/json/list', @uri.port)
|
119
|
-
targets = JSON.parse(response)
|
120
|
-
targets.find { |target| target['type'] == 'page' }
|
121
|
-
end
|
131
|
+
@ws ||= WebSocket::Handshake::Client.new(url: @url)
|
122
132
|
end
|
123
133
|
|
124
134
|
def next_id
|
@@ -33,14 +33,10 @@ module Selenium
|
|
33
33
|
:edge
|
34
34
|
end
|
35
35
|
|
36
|
-
def bridge_class
|
37
|
-
Bridge
|
38
|
-
end
|
39
|
-
|
40
36
|
private
|
41
37
|
|
42
|
-
def
|
43
|
-
capabilities['ms:edgeOptions']['debuggerAddress']
|
38
|
+
def devtools_address
|
39
|
+
"http://#{capabilities['ms:edgeOptions']['debuggerAddress']}"
|
44
40
|
end
|
45
41
|
end # Driver
|
46
42
|
end # Edge
|
File without changes
|
File without changes
|
@@ -22,7 +22,7 @@ require 'net/http'
|
|
22
22
|
module Selenium
|
23
23
|
module WebDriver
|
24
24
|
module Edge
|
25
|
-
autoload :
|
25
|
+
autoload :Features, 'selenium/webdriver/edge/features'
|
26
26
|
autoload :Driver, 'selenium/webdriver/edge/driver'
|
27
27
|
autoload :Profile, 'selenium/webdriver/edge/profile'
|
28
28
|
autoload :Options, 'selenium/webdriver/edge/options'
|
@@ -27,28 +27,29 @@ module Selenium
|
|
27
27
|
#
|
28
28
|
|
29
29
|
class Driver < WebDriver::Driver
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
EXTENSIONS = [DriverExtensions::HasAddons,
|
31
|
+
DriverExtensions::FullPageScreenshot,
|
32
|
+
DriverExtensions::HasDevTools,
|
33
|
+
DriverExtensions::HasLogEvents,
|
34
|
+
DriverExtensions::HasNetworkInterception,
|
35
|
+
DriverExtensions::HasWebStorage,
|
36
|
+
DriverExtensions::PrintsPage].freeze
|
35
37
|
|
36
38
|
def browser
|
37
39
|
:firefox
|
38
40
|
end
|
39
41
|
|
40
|
-
def bridge_class
|
41
|
-
Bridge
|
42
|
-
end
|
43
|
-
|
44
42
|
private
|
45
43
|
|
46
|
-
def
|
47
|
-
|
44
|
+
def devtools_url
|
45
|
+
uri = URI("http://#{capabilities['moz:debuggerAddress']}")
|
46
|
+
response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
|
47
|
+
|
48
|
+
JSON.parse(response)['webSocketDebuggerUrl']
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
-
|
51
|
+
def devtools_version
|
52
|
+
Firefox::DEVTOOLS_VERSION
|
52
53
|
end
|
53
54
|
end # Driver
|
54
55
|
end # Firefox
|