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
@@ -21,8 +21,35 @@ module Selenium
|
|
21
21
|
module WebDriver
|
22
22
|
module DriverExtensions
|
23
23
|
module PrintsPage
|
24
|
+
#
|
25
|
+
# Save a page as a PDF to the given path
|
26
|
+
#
|
27
|
+
# @example Save Printed Page
|
28
|
+
# driver.save_print_page('../printed_page.pdf')
|
29
|
+
#
|
30
|
+
# @param [String] path to where the pdf should be saved
|
31
|
+
#
|
32
|
+
# @api public
|
33
|
+
#
|
34
|
+
|
35
|
+
def save_print_page(path, **options)
|
36
|
+
File.open(path, 'wb') do |file|
|
37
|
+
content = Base64.decode64 print_page(options)
|
38
|
+
file << content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
#
|
43
|
+
# Return a Base64 encoded Print Page as a string
|
44
|
+
#
|
45
|
+
# @see https://w3c.github.io/webdriver/#print-page
|
46
|
+
#
|
47
|
+
# @api public
|
48
|
+
#
|
49
|
+
|
24
50
|
def print_page(**options)
|
25
|
-
options[:
|
51
|
+
options[:pageRanges] = Array(options.delete(:page_ranges)) || []
|
52
|
+
options[:shrinkToFit] = options.delete(:shrink_to_fit) { true }
|
26
53
|
|
27
54
|
@bridge.print_page(options)
|
28
55
|
end
|
@@ -92,13 +92,18 @@ module Selenium
|
|
92
92
|
end
|
93
93
|
|
94
94
|
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
95
|
+
# This method attempts to provide the most likely desired current value for the attribute
|
96
|
+
# of the element, even when that desired value is actually a JavaScript property.
|
97
|
+
# It is implemented with a custom JavaScript atom. To obtain the exact value of the attribute or property,
|
98
|
+
# use #dom_attribute or #property methods respectively.
|
99
|
+
#
|
100
|
+
# More exactly, this method will return the value of the property with the given name,
|
101
|
+
# if it exists. If it does not, then the value of the attribute with the given name is returned.
|
102
|
+
# If neither exists, null is returned.
|
103
|
+
#
|
104
|
+
# The "style" attribute is converted as best can be to a text representation with a trailing semi-colon.
|
105
|
+
#
|
106
|
+
# The following are deemed to be "boolean" attributes, and will return either "true" or "false":
|
102
107
|
#
|
103
108
|
# async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
|
104
109
|
# defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
@@ -106,29 +111,73 @@ module Selenium
|
|
106
111
|
# nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
107
112
|
# selected, spellcheck, truespeed, willvalidate
|
108
113
|
#
|
109
|
-
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as
|
110
|
-
# expected:
|
114
|
+
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
|
111
115
|
#
|
112
|
-
# class,
|
116
|
+
# When the value of "class" is requested, the "className" property is returned.
|
117
|
+
# When the value of "readonly" is requested, the "readOnly" property is returned.
|
113
118
|
#
|
114
119
|
# @param [String] name attribute name
|
115
120
|
# @return [String, nil] attribute value
|
116
121
|
#
|
122
|
+
# @see #dom_attribute
|
123
|
+
# @see #property
|
124
|
+
#
|
117
125
|
|
118
126
|
def attribute(name)
|
119
127
|
bridge.element_attribute self, name
|
120
128
|
end
|
121
129
|
|
122
130
|
#
|
123
|
-
#
|
124
|
-
#
|
131
|
+
# Gets the value of a declared HTML attribute of this element.
|
132
|
+
#
|
133
|
+
# As opposed to the #attribute method, this method
|
134
|
+
# only returns attributes declared in the element's HTML markup.
|
135
|
+
#
|
136
|
+
# If the attribute is not set, nil is returned.
|
137
|
+
#
|
138
|
+
# @param [String] name attribute name
|
139
|
+
# @return [String, nil] attribute value
|
140
|
+
#
|
141
|
+
# @see #attribute
|
142
|
+
# @see #property
|
143
|
+
#
|
144
|
+
|
145
|
+
def dom_attribute(name)
|
146
|
+
bridge.element_dom_attribute @id, name
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# Gets the value of a JavaScript property of this element
|
151
|
+
# This will return the current value,
|
152
|
+
# even if this has been modified after the page has been loaded.
|
153
|
+
# If the value is not set, nil is returned.
|
125
154
|
#
|
126
155
|
# @param [String] name property name
|
127
156
|
# @return [String, nil] property value
|
128
157
|
#
|
129
158
|
|
130
159
|
def property(name)
|
131
|
-
bridge.element_property
|
160
|
+
bridge.element_property @id, name
|
161
|
+
end
|
162
|
+
|
163
|
+
#
|
164
|
+
# Gets the computed WAI-ARIA role of element
|
165
|
+
#
|
166
|
+
# @return [String]
|
167
|
+
#
|
168
|
+
|
169
|
+
def aria_role
|
170
|
+
bridge.element_aria_role @id
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Gets the computed WAI-ARIA label of element.
|
175
|
+
#
|
176
|
+
# @return [String]
|
177
|
+
#
|
178
|
+
|
179
|
+
def accessible_name
|
180
|
+
bridge.element_aria_label @id
|
132
181
|
end
|
133
182
|
|
134
183
|
#
|
@@ -268,6 +317,16 @@ module Selenium
|
|
268
317
|
bridge.element_size @id
|
269
318
|
end
|
270
319
|
|
320
|
+
#
|
321
|
+
# Returns the shadow root of an element.
|
322
|
+
#
|
323
|
+
# @return [WebDriver::ShadowRoot]
|
324
|
+
#
|
325
|
+
|
326
|
+
def shadow_root
|
327
|
+
bridge.shadow_root @id
|
328
|
+
end
|
329
|
+
|
271
330
|
#-------------------------------- sugar --------------------------------
|
272
331
|
|
273
332
|
#
|
@@ -287,14 +346,13 @@ module Selenium
|
|
287
346
|
#
|
288
347
|
alias_method :[], :attribute
|
289
348
|
|
290
|
-
#
|
291
|
-
# for SearchContext and execute_script
|
292
349
|
#
|
293
350
|
# @api private
|
351
|
+
# @see SearchContext
|
294
352
|
#
|
295
353
|
|
296
354
|
def ref
|
297
|
-
@id
|
355
|
+
[:element, @id]
|
298
356
|
end
|
299
357
|
|
300
358
|
#
|
@@ -330,7 +388,7 @@ module Selenium
|
|
330
388
|
end
|
331
389
|
|
332
390
|
def screenshot
|
333
|
-
bridge.element_screenshot(
|
391
|
+
bridge.element_screenshot(@id)
|
334
392
|
end
|
335
393
|
end # Element
|
336
394
|
end # WebDriver
|
@@ -61,6 +61,12 @@ module Selenium
|
|
61
61
|
|
62
62
|
class StaleElementReferenceError < WebDriverError; end
|
63
63
|
|
64
|
+
#
|
65
|
+
# A command failed because the referenced shadow root is no longer attached to the DOM.
|
66
|
+
#
|
67
|
+
|
68
|
+
class DetachedShadowRootError < WebDriverError; end
|
69
|
+
|
64
70
|
#
|
65
71
|
# The target element is in an invalid state, rendering it impossible to interact with, for
|
66
72
|
# example if you click a disabled element.
|
@@ -93,6 +99,12 @@ module Selenium
|
|
93
99
|
|
94
100
|
class NoSuchWindowError < WebDriverError; end
|
95
101
|
|
102
|
+
#
|
103
|
+
# The element does not have a shadow root.
|
104
|
+
#
|
105
|
+
|
106
|
+
class NoSuchShadowRootError < WebDriverError; end
|
107
|
+
|
96
108
|
#
|
97
109
|
# An illegal attempt was made to set a cookie under a different domain than the current page.
|
98
110
|
#
|
@@ -26,7 +26,10 @@ module Selenium
|
|
26
26
|
attr_reader :source
|
27
27
|
|
28
28
|
def initialize(source)
|
29
|
-
|
29
|
+
unless Interactions::SOURCE_TYPES.include? source.type
|
30
|
+
raise TypeError,
|
31
|
+
"#{source.type} is not a valid input type"
|
32
|
+
end
|
30
33
|
|
31
34
|
@source = source
|
32
35
|
end
|
@@ -108,10 +108,11 @@ module Selenium
|
|
108
108
|
#
|
109
109
|
# @param [String] old
|
110
110
|
# @param [String, nil] new
|
111
|
-
# @param [Symbol, Array<
|
111
|
+
# @param [Symbol, Array<Symbol>] id
|
112
|
+
# @param [String] reference
|
112
113
|
# @yield appends additional message to end of provided template
|
113
114
|
#
|
114
|
-
def deprecate(old, new = nil, id: [], &block)
|
115
|
+
def deprecate(old, new = nil, id: [], reference: '', &block)
|
115
116
|
id = Array(id)
|
116
117
|
return if @ignored.include?(:deprecations) || (@ignored & id).any?
|
117
118
|
|
@@ -123,6 +124,8 @@ module Selenium
|
|
123
124
|
else
|
124
125
|
' and will be removed in a future release.'
|
125
126
|
end
|
127
|
+
message << " See explanation for this deprecation: #{reference}." unless reference.empty?
|
128
|
+
|
126
129
|
warn message, &block
|
127
130
|
end
|
128
131
|
|
@@ -23,16 +23,42 @@ module Selenium
|
|
23
23
|
W3C_OPTIONS = %i[browser_name browser_version platform_name accept_insecure_certs page_load_strategy proxy
|
24
24
|
set_window_rect timeouts unhandled_prompt_behavior strict_file_interactability].freeze
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
next if method_defined? key
|
26
|
+
class << self
|
27
|
+
attr_reader :driver_path
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
def chrome(**opts)
|
30
|
+
Chrome::Options.new(**opts)
|
31
|
+
end
|
32
|
+
|
33
|
+
def firefox(**opts)
|
34
|
+
Firefox::Options.new(**opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
def ie(**opts)
|
38
|
+
IE::Options.new(**opts)
|
39
|
+
end
|
40
|
+
alias_method :internet_explorer, :ie
|
41
|
+
|
42
|
+
def edge(**opts)
|
43
|
+
Edge::Options.new(**opts)
|
44
|
+
end
|
45
|
+
alias_method :microsoftedge, :edge
|
46
|
+
|
47
|
+
def safari(**opts)
|
48
|
+
Safari::Options.new(**opts)
|
49
|
+
end
|
50
|
+
|
51
|
+
def set_capabilities
|
52
|
+
(W3C_OPTIONS + self::CAPABILITIES.keys).each do |key|
|
53
|
+
next if method_defined? key
|
33
54
|
|
34
|
-
|
35
|
-
|
55
|
+
define_method key do
|
56
|
+
@options[key]
|
57
|
+
end
|
58
|
+
|
59
|
+
define_method "#{key}=" do |value|
|
60
|
+
@options[key] = value
|
61
|
+
end
|
36
62
|
end
|
37
63
|
end
|
38
64
|
end
|
@@ -68,6 +94,14 @@ module Selenium
|
|
68
94
|
@options[name] = value
|
69
95
|
end
|
70
96
|
|
97
|
+
def ==(other)
|
98
|
+
return false unless other.is_a? self.class
|
99
|
+
|
100
|
+
as_json == other.as_json
|
101
|
+
end
|
102
|
+
|
103
|
+
alias_method :eql?, :==
|
104
|
+
|
71
105
|
#
|
72
106
|
# @api private
|
73
107
|
#
|
@@ -75,12 +109,11 @@ module Selenium
|
|
75
109
|
def as_json(*)
|
76
110
|
options = @options.dup
|
77
111
|
|
78
|
-
w3c_options = options
|
79
|
-
options.delete_if { |key, _val| W3C_OPTIONS.include?(key) }
|
112
|
+
w3c_options = process_w3c_options(options)
|
80
113
|
|
81
114
|
self.class::CAPABILITIES.each do |capability_alias, capability_name|
|
82
115
|
capability_value = options.delete(capability_alias)
|
83
|
-
options[capability_name] = capability_value
|
116
|
+
options[capability_name] = capability_value if !capability_value.nil? && !options.key?(capability_name)
|
84
117
|
end
|
85
118
|
browser_options = defined?(self.class::KEY) ? {self.class::KEY => options} : options
|
86
119
|
|
@@ -90,6 +123,13 @@ module Selenium
|
|
90
123
|
|
91
124
|
private
|
92
125
|
|
126
|
+
def process_w3c_options(options)
|
127
|
+
w3c_options = options.select { |key, _val| W3C_OPTIONS.include?(key) }
|
128
|
+
w3c_options[:unhandled_prompt_behavior] &&= w3c_options[:unhandled_prompt_behavior]&.to_s&.tr('_', ' ')
|
129
|
+
options.delete_if { |key, _val| W3C_OPTIONS.include?(key) }
|
130
|
+
w3c_options
|
131
|
+
end
|
132
|
+
|
93
133
|
def process_browser_options(_browser_options)
|
94
134
|
nil
|
95
135
|
end
|
@@ -100,12 +140,7 @@ module Selenium
|
|
100
140
|
|
101
141
|
def generate_as_json(value, camelize_keys: true)
|
102
142
|
if value.is_a?(Hash)
|
103
|
-
value
|
104
|
-
next if val.respond_to?(:empty?) && val.empty?
|
105
|
-
|
106
|
-
key = convert_json_key(key, camelize: camelize_keys)
|
107
|
-
hash[key] = generate_as_json(val, camelize_keys: camelize?(key))
|
108
|
-
end
|
143
|
+
process_json_hash(value, camelize_keys)
|
109
144
|
elsif value.respond_to?(:as_json)
|
110
145
|
value.as_json
|
111
146
|
elsif value.is_a?(Array)
|
@@ -117,6 +152,16 @@ module Selenium
|
|
117
152
|
end
|
118
153
|
end
|
119
154
|
|
155
|
+
def process_json_hash(value, camelize_keys)
|
156
|
+
value.each_with_object({}) do |(key, val), hash|
|
157
|
+
next if val.respond_to?(:empty?) && val.empty?
|
158
|
+
|
159
|
+
camelize = camelize_keys ? camelize?(key) : false
|
160
|
+
key = convert_json_key(key, camelize: camelize)
|
161
|
+
hash[key] = generate_as_json(val, camelize_keys: camelize)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
120
165
|
def convert_json_key(key, camelize: true)
|
121
166
|
key = key.to_s if key.is_a?(Symbol)
|
122
167
|
key = camel_case(key) if camelize
|
@@ -127,7 +127,10 @@ module Selenium
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def type=(type)
|
130
|
-
|
130
|
+
unless TYPES.key? type
|
131
|
+
raise ArgumentError,
|
132
|
+
"invalid proxy type: #{type.inspect}, expected one of #{TYPES.keys.inspect}"
|
133
|
+
end
|
131
134
|
|
132
135
|
if defined?(@type) && type != @type
|
133
136
|
raise ArgumentError, "incompatible proxy type #{type.inspect} (already set to #{@type.inspect})"
|
@@ -138,10 +141,10 @@ module Selenium
|
|
138
141
|
|
139
142
|
def as_json(*)
|
140
143
|
json_result = {
|
141
|
-
'proxyType' => TYPES[type],
|
144
|
+
'proxyType' => TYPES[type].downcase,
|
142
145
|
'ftpProxy' => ftp,
|
143
146
|
'httpProxy' => http,
|
144
|
-
'noProxy' => no_proxy,
|
147
|
+
'noProxy' => no_proxy.is_a?(String) ? no_proxy.split(', ') : no_proxy,
|
145
148
|
'proxyAutoconfigUrl' => pac,
|
146
149
|
'sslProxy' => ssl,
|
147
150
|
'autodetect' => auto_detect,
|
@@ -93,7 +93,10 @@ module Selenium
|
|
93
93
|
when 1
|
94
94
|
arg = args.first
|
95
95
|
|
96
|
-
|
96
|
+
unless arg.respond_to?(:shift)
|
97
|
+
raise ArgumentError,
|
98
|
+
"expected #{arg.inspect}:#{arg.class} to respond to #shift"
|
99
|
+
end
|
97
100
|
|
98
101
|
# this will be a single-entry hash, so use #shift over #first or #[]
|
99
102
|
arr = arg.dup.shift
|
@@ -0,0 +1,87 @@
|
|
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
|
+
class ShadowRoot
|
23
|
+
ROOT_KEY = 'shadow-6066-11e4-a52e-4f735466cecf'
|
24
|
+
|
25
|
+
include SearchContext
|
26
|
+
|
27
|
+
#
|
28
|
+
# Creates a new shadow root
|
29
|
+
#
|
30
|
+
# @api private
|
31
|
+
#
|
32
|
+
|
33
|
+
def initialize(bridge, id)
|
34
|
+
@bridge = bridge
|
35
|
+
@id = id
|
36
|
+
end
|
37
|
+
|
38
|
+
def inspect
|
39
|
+
format '#<%<class>s:0x%<hash>x id=%<id>s>', class: self.class, hash: hash * 2, id: @id.inspect
|
40
|
+
end
|
41
|
+
|
42
|
+
def ==(other)
|
43
|
+
other.is_a?(self.class) && ref == other.ref
|
44
|
+
end
|
45
|
+
alias_method :eql?, :==
|
46
|
+
|
47
|
+
def hash
|
48
|
+
@id.hash ^ @bridge.hash
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# @api private
|
53
|
+
# @see SearchContext
|
54
|
+
#
|
55
|
+
|
56
|
+
def ref
|
57
|
+
[:shadow_root, @id]
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Convert to a ShadowRoot JSON Object for transmission over the wire.
|
62
|
+
# @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#basic-terms-and-concepts
|
63
|
+
#
|
64
|
+
# @api private
|
65
|
+
#
|
66
|
+
|
67
|
+
def to_json(*)
|
68
|
+
JSON.generate as_json
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# For Rails 3 - http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
|
73
|
+
#
|
74
|
+
# @api private
|
75
|
+
#
|
76
|
+
|
77
|
+
def as_json(*)
|
78
|
+
{ROOT_KEY => @id}
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
attr_reader :bridge
|
84
|
+
|
85
|
+
end # ShadowRoot
|
86
|
+
end # WebDriver
|
87
|
+
end # Selenium
|