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
@@ -24,7 +24,8 @@ module Selenium
|
|
24
24
|
|
25
25
|
FIREFOX_COMMANDS = {
|
26
26
|
install_addon: [:post, 'session/:session_id/moz/addon/install'],
|
27
|
-
uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
|
27
|
+
uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'],
|
28
|
+
full_page_screenshot: [:get, 'session/:session_id/moz/screenshot/full']
|
28
29
|
}.freeze
|
29
30
|
|
30
31
|
def commands(command)
|
@@ -41,6 +42,10 @@ module Selenium
|
|
41
42
|
execute :uninstall_addon, {}, {id: id}
|
42
43
|
end
|
43
44
|
|
45
|
+
def full_screenshot
|
46
|
+
execute :full_page_screenshot
|
47
|
+
end
|
48
|
+
|
44
49
|
end # Bridge
|
45
50
|
end # Firefox
|
46
51
|
end # WebDriver
|
@@ -27,7 +27,7 @@ module Selenium
|
|
27
27
|
autoload :Extension, 'selenium/webdriver/firefox/extension'
|
28
28
|
autoload :ProfilesIni, 'selenium/webdriver/firefox/profiles_ini'
|
29
29
|
autoload :Profile, 'selenium/webdriver/firefox/profile'
|
30
|
-
autoload :
|
30
|
+
autoload :Features, 'selenium/webdriver/firefox/features'
|
31
31
|
autoload :Driver, 'selenium/webdriver/firefox/driver'
|
32
32
|
autoload :Options, 'selenium/webdriver/firefox/options'
|
33
33
|
autoload :Service, 'selenium/webdriver/firefox/service'
|
@@ -38,6 +38,10 @@ module Selenium
|
|
38
38
|
DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
|
39
39
|
DEFAULT_LOAD_NO_FOCUS_LIB = false
|
40
40
|
|
41
|
+
# Mozilla Automation Team asked to only support 85
|
42
|
+
# until WebDriver Bidi is available.
|
43
|
+
DEVTOOLS_VERSION = 85
|
44
|
+
|
41
45
|
def self.driver_path=(path)
|
42
46
|
WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path=',
|
43
47
|
'Selenium::WebDriver::Firefox::Service#driver_path=',
|
@@ -39,7 +39,9 @@ module Selenium
|
|
39
39
|
persistent_hover: 'enablePersistentHover',
|
40
40
|
require_window_focus: 'requireWindowFocus',
|
41
41
|
use_per_process_proxy: 'ie.usePerProcessProxy',
|
42
|
-
|
42
|
+
use_legacy_file_upload_dialog_handling: 'ie.useLegacyFileUploadDialogHandling',
|
43
|
+
attach_to_edge_chrome: 'ie.edgechromium',
|
44
|
+
edge_executable_path: 'ie.edgepath'
|
43
45
|
}.freeze
|
44
46
|
BROWSER = 'internet explorer'
|
45
47
|
|
@@ -25,7 +25,7 @@ module Selenium
|
|
25
25
|
EXECUTABLE = 'IEDriverServer'
|
26
26
|
MISSING_TEXT = <<~ERROR
|
27
27
|
Unable to find IEDriverServer. Please download the server from
|
28
|
-
|
28
|
+
https://www.selenium.dev/downloads/ and place it somewhere on your PATH.
|
29
29
|
More info at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
|
30
30
|
ERROR
|
31
31
|
SHUTDOWN_SUPPORTED = true
|
@@ -38,7 +38,9 @@ module Selenium
|
|
38
38
|
driver_opts = driver_opts.dup
|
39
39
|
driver_args << "--log-level=#{driver_opts[:log_level].to_s.upcase}" if driver_opts.key?(:log_level)
|
40
40
|
driver_args << "--log-file=#{driver_opts[:log_file]}" if driver_opts.key?(:log_file)
|
41
|
-
|
41
|
+
if driver_opts.key?(:implementation)
|
42
|
+
driver_args << "--implementation=#{driver_opts[:implementation].to_s.upcase}"
|
43
|
+
end
|
42
44
|
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
|
43
45
|
driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
|
44
46
|
driver_args << "--silent" if driver_opts[:silent] == true
|
@@ -49,7 +49,7 @@ module Selenium
|
|
49
49
|
#
|
50
50
|
|
51
51
|
def create_session(capabilities)
|
52
|
-
response = execute(:new_session, {},
|
52
|
+
response = execute(:new_session, {}, prepare_capabilities_payload(capabilities))
|
53
53
|
|
54
54
|
@session_id = response['sessionId']
|
55
55
|
capabilities = response['capabilities']
|
@@ -57,6 +57,17 @@ module Selenium
|
|
57
57
|
raise Error::WebDriverError, 'no sessionId in returned payload' unless @session_id
|
58
58
|
|
59
59
|
@capabilities = Capabilities.json_create(capabilities)
|
60
|
+
|
61
|
+
case @capabilities[:browser_name]
|
62
|
+
when 'chrome'
|
63
|
+
extend(WebDriver::Chrome::Features)
|
64
|
+
when 'firefox'
|
65
|
+
extend(WebDriver::Firefox::Features)
|
66
|
+
when 'msedge'
|
67
|
+
extend(WebDriver::Edge::Features)
|
68
|
+
when 'Safari', 'Safari Technology Preview'
|
69
|
+
extend(WebDriver::Safari::Features)
|
70
|
+
end
|
60
71
|
end
|
61
72
|
|
62
73
|
#
|
@@ -70,7 +81,7 @@ module Selenium
|
|
70
81
|
def browser
|
71
82
|
@browser ||= begin
|
72
83
|
name = @capabilities.browser_name
|
73
|
-
name ? name.tr(' ', '_').to_sym : 'unknown'
|
84
|
+
name ? name.tr(' ', '_').downcase.to_sym : 'unknown'
|
74
85
|
end
|
75
86
|
end
|
76
87
|
|
@@ -207,7 +218,10 @@ module Selenium
|
|
207
218
|
end
|
208
219
|
|
209
220
|
def window_size(handle = :current)
|
210
|
-
|
221
|
+
unless handle == :current
|
222
|
+
raise Error::UnsupportedOperationError,
|
223
|
+
'Switch to desired window before getting its size'
|
224
|
+
end
|
211
225
|
|
212
226
|
data = execute :get_window_rect
|
213
227
|
Dimension.new data['width'], data['height']
|
@@ -218,7 +232,10 @@ module Selenium
|
|
218
232
|
end
|
219
233
|
|
220
234
|
def maximize_window(handle = :current)
|
221
|
-
|
235
|
+
unless handle == :current
|
236
|
+
raise Error::UnsupportedOperationError,
|
237
|
+
'Switch to desired window before changing its size'
|
238
|
+
end
|
222
239
|
|
223
240
|
execute :maximize_window
|
224
241
|
end
|
@@ -252,7 +269,7 @@ module Selenium
|
|
252
269
|
end
|
253
270
|
|
254
271
|
def element_screenshot(element)
|
255
|
-
execute :take_element_screenshot, id: element
|
272
|
+
execute :take_element_screenshot, id: element
|
256
273
|
end
|
257
274
|
|
258
275
|
#
|
@@ -414,7 +431,7 @@ module Selenium
|
|
414
431
|
end
|
415
432
|
|
416
433
|
def submit_element(element)
|
417
|
-
form = find_element_by('xpath', "./ancestor-or-self::form", element)
|
434
|
+
form = find_element_by('xpath', "./ancestor-or-self::form", [:element, element])
|
418
435
|
execute_script("var e = arguments[0].ownerDocument.createEvent('Event');" \
|
419
436
|
"e.initEvent('submit', true, true);" \
|
420
437
|
'if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }', form.as_json)
|
@@ -433,8 +450,20 @@ module Selenium
|
|
433
450
|
execute_atom :getAttribute, element, name
|
434
451
|
end
|
435
452
|
|
453
|
+
def element_dom_attribute(element, name)
|
454
|
+
execute :get_element_attribute, id: element, name: name
|
455
|
+
end
|
456
|
+
|
436
457
|
def element_property(element, name)
|
437
|
-
execute :get_element_property, id: element
|
458
|
+
execute :get_element_property, id: element, name: name
|
459
|
+
end
|
460
|
+
|
461
|
+
def element_aria_role(element)
|
462
|
+
execute :get_element_aria_role, id: element
|
463
|
+
end
|
464
|
+
|
465
|
+
def element_aria_label(element)
|
466
|
+
execute :get_element_aria_label, id: element
|
438
467
|
end
|
439
468
|
|
440
469
|
def element_value(element)
|
@@ -495,13 +524,17 @@ module Selenium
|
|
495
524
|
|
496
525
|
alias_method :switch_to_active_element, :active_element
|
497
526
|
|
498
|
-
def find_element_by(how, what,
|
527
|
+
def find_element_by(how, what, parent_ref = [])
|
499
528
|
how, what = convert_locator(how, what)
|
500
529
|
|
501
530
|
return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'
|
502
531
|
|
503
|
-
|
504
|
-
|
532
|
+
parent_type, parent_id = parent_ref
|
533
|
+
id = case parent_type
|
534
|
+
when :element
|
535
|
+
execute :find_child_element, {id: parent_id}, {using: how, value: what.to_s}
|
536
|
+
when :shadow_root
|
537
|
+
execute :find_shadow_child_element, {id: parent_id}, {using: how, value: what.to_s}
|
505
538
|
else
|
506
539
|
execute :find_element, {}, {using: how, value: what.to_s}
|
507
540
|
end
|
@@ -509,13 +542,17 @@ module Selenium
|
|
509
542
|
Element.new self, element_id_from(id)
|
510
543
|
end
|
511
544
|
|
512
|
-
def find_elements_by(how, what,
|
545
|
+
def find_elements_by(how, what, parent_ref = [])
|
513
546
|
how, what = convert_locator(how, what)
|
514
547
|
|
515
548
|
return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative'
|
516
549
|
|
517
|
-
|
518
|
-
|
550
|
+
parent_type, parent_id = parent_ref
|
551
|
+
ids = case parent_type
|
552
|
+
when :element
|
553
|
+
execute :find_child_elements, {id: parent_id}, {using: how, value: what.to_s}
|
554
|
+
when :shadow_root
|
555
|
+
execute :find_shadow_child_elements, {id: parent_id}, {using: how, value: what.to_s}
|
519
556
|
else
|
520
557
|
execute :find_elements, {}, {using: how, value: what.to_s}
|
521
558
|
end
|
@@ -523,6 +560,11 @@ module Selenium
|
|
523
560
|
ids.map { |id| Element.new self, element_id_from(id) }
|
524
561
|
end
|
525
562
|
|
563
|
+
def shadow_root(element)
|
564
|
+
id = execute :get_element_shadow_root, id: element
|
565
|
+
ShadowRoot.new self, shadow_root_id_from(id)
|
566
|
+
end
|
567
|
+
|
526
568
|
private
|
527
569
|
|
528
570
|
#
|
@@ -570,7 +612,16 @@ module Selenium
|
|
570
612
|
end
|
571
613
|
|
572
614
|
def element_id_from(id)
|
573
|
-
id['ELEMENT'] || id[
|
615
|
+
id['ELEMENT'] || id[Element::ELEMENT_KEY]
|
616
|
+
end
|
617
|
+
|
618
|
+
def shadow_root_id_from(id)
|
619
|
+
id[ShadowRoot::ROOT_KEY]
|
620
|
+
end
|
621
|
+
|
622
|
+
def prepare_capabilities_payload(capabilities)
|
623
|
+
capabilities = {alwaysMatch: capabilities} if !capabilities['alwaysMatch'] && !capabilities['firstMatch']
|
624
|
+
{capabilities: capabilities}
|
574
625
|
end
|
575
626
|
|
576
627
|
def convert_locator(how, what)
|
@@ -40,22 +40,15 @@ module Selenium
|
|
40
40
|
:unhandled_prompt_behavior,
|
41
41
|
:strict_file_interactability,
|
42
42
|
|
43
|
-
# remote-specific
|
44
|
-
:remote_session_id
|
45
|
-
|
46
|
-
# TODO: (AR) deprecate compatibility with OSS-capabilities
|
47
|
-
:implicit_timeout,
|
48
|
-
:page_load_timeout,
|
49
|
-
:script_timeout
|
43
|
+
# remote-specific (webdriver.remote.sessionid)
|
44
|
+
:remote_session_id
|
50
45
|
].freeze
|
51
46
|
|
52
|
-
KNOWN.each do |key|
|
47
|
+
(KNOWN - %i[proxy timeouts]).each do |key|
|
53
48
|
define_method key do
|
54
|
-
@capabilities
|
49
|
+
@capabilities[key]
|
55
50
|
end
|
56
51
|
|
57
|
-
next if key == :proxy
|
58
|
-
|
59
52
|
define_method "#{key}=" do |value|
|
60
53
|
@capabilities[key] = value
|
61
54
|
end
|
@@ -86,18 +79,13 @@ module Selenium
|
|
86
79
|
browser_name: 'MicrosoftEdge'
|
87
80
|
}.merge(opts))
|
88
81
|
end
|
82
|
+
alias_method :microsoftedge, :edge
|
89
83
|
|
90
84
|
def firefox(opts = {})
|
91
|
-
|
92
|
-
|
93
|
-
opts
|
94
|
-
opts[:timeouts]['implicit'] = opts.delete(:implicit_timeout) if opts.key?(:implicit_timeout)
|
95
|
-
opts[:timeouts]['pageLoad'] = opts.delete(:page_load_timeout) if opts.key?(:page_load_timeout)
|
96
|
-
opts[:timeouts]['script'] = opts.delete(:script_timeout) if opts.key?(:script_timeout)
|
97
|
-
opts.delete(:timeouts) if opts[:timeouts].empty?
|
98
|
-
new({browser_name: 'firefox'}.merge(opts))
|
85
|
+
new({
|
86
|
+
browser_name: 'firefox'
|
87
|
+
}.merge(opts))
|
99
88
|
end
|
100
|
-
|
101
89
|
alias_method :ff, :firefox
|
102
90
|
|
103
91
|
def safari(opts = {})
|
@@ -120,19 +108,21 @@ module Selenium
|
|
120
108
|
end
|
121
109
|
alias_method :ie, :internet_explorer
|
122
110
|
|
111
|
+
def always_match(capabilities)
|
112
|
+
new(always_match: capabilities)
|
113
|
+
end
|
114
|
+
|
115
|
+
def first_match(*capabilities)
|
116
|
+
new(first_match: capabilities)
|
117
|
+
end
|
118
|
+
|
123
119
|
#
|
124
120
|
# @api private
|
125
121
|
#
|
126
122
|
|
127
123
|
def json_create(data)
|
128
124
|
data = data.dup
|
129
|
-
|
130
125
|
caps = new
|
131
|
-
caps.browser_name = data.delete('browserName') if data.key?('browserName')
|
132
|
-
caps.browser_version = data.delete('browserVersion') if data.key?('browserVersion')
|
133
|
-
caps.platform_name = data.delete('platformName') if data.key?('platformName')
|
134
|
-
caps.accept_insecure_certs = data.delete('acceptInsecureCerts') if data.key?('acceptInsecureCerts')
|
135
|
-
caps.page_load_strategy = data.delete('pageLoadStrategy') if data.key?('pageLoadStrategy')
|
136
126
|
|
137
127
|
process_timeouts(caps, data.delete('timeouts'))
|
138
128
|
|
@@ -142,7 +132,14 @@ module Selenium
|
|
142
132
|
end
|
143
133
|
|
144
134
|
# Remote Server Specific
|
145
|
-
|
135
|
+
if data.key?('webdriver.remote.sessionid')
|
136
|
+
caps[:remote_session_id] = data.delete('webdriver.remote.sessionid')
|
137
|
+
end
|
138
|
+
|
139
|
+
KNOWN.each do |cap|
|
140
|
+
data_value = camel_case(cap)
|
141
|
+
caps[cap] = data.delete(data_value) if data.key?(data_value)
|
142
|
+
end
|
146
143
|
|
147
144
|
# any remaining pairs will be added as is, with no conversion
|
148
145
|
caps.merge!(data)
|
@@ -150,6 +147,10 @@ module Selenium
|
|
150
147
|
caps
|
151
148
|
end
|
152
149
|
|
150
|
+
def camel_case(str_or_sym)
|
151
|
+
str_or_sym.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
152
|
+
end
|
153
|
+
|
153
154
|
private
|
154
155
|
|
155
156
|
def process_timeouts(caps, timeouts)
|
@@ -173,8 +174,9 @@ module Selenium
|
|
173
174
|
#
|
174
175
|
|
175
176
|
def initialize(opts = {})
|
176
|
-
@capabilities =
|
177
|
-
self.proxy = opts.delete(:proxy)
|
177
|
+
@capabilities = {}
|
178
|
+
self.proxy = opts.delete(:proxy) if opts[:proxy]
|
179
|
+
@capabilities.merge!(opts)
|
178
180
|
end
|
179
181
|
|
180
182
|
#
|
@@ -199,6 +201,10 @@ module Selenium
|
|
199
201
|
end
|
200
202
|
end
|
201
203
|
|
204
|
+
def proxy
|
205
|
+
@capabilities[:proxy]
|
206
|
+
end
|
207
|
+
|
202
208
|
def proxy=(proxy)
|
203
209
|
case proxy
|
204
210
|
when Hash
|
@@ -210,33 +216,46 @@ module Selenium
|
|
210
216
|
end
|
211
217
|
end
|
212
218
|
|
219
|
+
def timeouts
|
220
|
+
@capabilities[:timeouts] ||= {}
|
221
|
+
end
|
222
|
+
|
223
|
+
def timeouts=(timeouts)
|
224
|
+
@capabilities[:timeouts] = timeouts
|
225
|
+
end
|
226
|
+
|
227
|
+
def implicit_timeout
|
228
|
+
timeouts[:implicit]
|
229
|
+
end
|
230
|
+
|
231
|
+
def implicit_timeout=(timeout)
|
232
|
+
timeouts[:implicit] = timeout
|
233
|
+
end
|
234
|
+
|
235
|
+
def page_load_timeout
|
236
|
+
timeouts[:page_load] || timeouts[:pageLoad]
|
237
|
+
end
|
238
|
+
|
239
|
+
def page_load_timeout=(timeout)
|
240
|
+
timeouts[:page_load] = timeout
|
241
|
+
end
|
242
|
+
|
243
|
+
def script_timeout
|
244
|
+
timeouts[:script]
|
245
|
+
end
|
246
|
+
|
247
|
+
def script_timeout=(timeout)
|
248
|
+
timeouts[:script] = timeout
|
249
|
+
end
|
250
|
+
|
213
251
|
#
|
214
252
|
# @api private
|
215
253
|
#
|
216
254
|
|
217
255
|
def as_json(*)
|
218
|
-
|
219
|
-
|
220
|
-
@capabilities.each do |key, value|
|
221
|
-
case key
|
222
|
-
when :platform
|
223
|
-
hash['platform'] = value.to_s.upcase
|
224
|
-
when :proxy
|
225
|
-
if value
|
226
|
-
hash['proxy'] = value.as_json
|
227
|
-
hash['proxy']['proxyType'] &&= hash['proxy']['proxyType'].downcase
|
228
|
-
hash['proxy']['noProxy'] = hash['proxy']['noProxy'].split(', ') if hash['proxy']['noProxy'].is_a?(String)
|
229
|
-
end
|
230
|
-
when String
|
231
|
-
hash[key.to_s] = value
|
232
|
-
when Symbol
|
233
|
-
hash[camel_case(key.to_s)] = value
|
234
|
-
else
|
235
|
-
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}"
|
236
|
-
end
|
256
|
+
@capabilities.each_with_object({}) do |(key, value), hash|
|
257
|
+
hash[convert_key(key)] = process_capabilities(key, value, hash)
|
237
258
|
end
|
238
|
-
|
239
|
-
hash
|
240
259
|
end
|
241
260
|
|
242
261
|
def to_json(*)
|
@@ -257,10 +276,44 @@ module Selenium
|
|
257
276
|
|
258
277
|
private
|
259
278
|
|
260
|
-
def
|
261
|
-
|
279
|
+
def process_capabilities(key, value, hash)
|
280
|
+
case value
|
281
|
+
when Array
|
282
|
+
value.map { |v| process_capabilities(key, v, hash) }
|
283
|
+
when Hash
|
284
|
+
value.each_with_object({}) do |(k, v), h|
|
285
|
+
h[convert_key(k)] = process_capabilities(k, v, h)
|
286
|
+
end
|
287
|
+
when Capabilities, Options
|
288
|
+
value.as_json
|
289
|
+
else
|
290
|
+
convert_value(key, value)
|
291
|
+
end
|
262
292
|
end
|
263
293
|
|
294
|
+
def convert_key(key)
|
295
|
+
case key
|
296
|
+
when String
|
297
|
+
key.to_s
|
298
|
+
when Symbol
|
299
|
+
self.class.camel_case(key)
|
300
|
+
else
|
301
|
+
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class}"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def convert_value(key, value)
|
306
|
+
case key
|
307
|
+
when :platform
|
308
|
+
value.to_s.upcase
|
309
|
+
when :proxy
|
310
|
+
value&.as_json
|
311
|
+
when :unhandled_prompt_behavior
|
312
|
+
value.is_a?(Symbol) ? value.to_s.tr('_', ' ') : value
|
313
|
+
else
|
314
|
+
value
|
315
|
+
end
|
316
|
+
end
|
264
317
|
end # Capabilities
|
265
318
|
end # Remote
|
266
319
|
end # WebDriver
|