selenium-webdriver 3.142.7 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +583 -5
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/server.rb +93 -78
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/atoms.rb +2 -3
- data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
- data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/filter_by.rb +40 -0
- data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log_inspector.rb +143 -0
- data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
- data/lib/selenium/webdriver/bidi/session.rb +51 -0
- data/lib/selenium/webdriver/{common/keyboard.rb → bidi.rb} +21 -35
- data/lib/selenium/webdriver/chrome/driver.rb +9 -86
- data/lib/selenium/webdriver/chrome/features.rb +44 -0
- data/lib/selenium/webdriver/chrome/options.rb +9 -158
- data/lib/selenium/webdriver/chrome/profile.rb +3 -80
- data/lib/selenium/webdriver/chrome/service.rb +6 -33
- data/lib/selenium/webdriver/chrome.rb +5 -18
- data/lib/selenium/webdriver/chromium/driver.rb +61 -0
- data/lib/selenium/webdriver/{chrome/bridge.rb → chromium/features.rb} +51 -16
- data/lib/selenium/webdriver/chromium/options.rb +261 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium/service.rb +42 -0
- data/lib/selenium/webdriver/chromium.rb +32 -0
- data/lib/selenium/webdriver/common/action_builder.rb +135 -237
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +94 -43
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +49 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +87 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +9 -9
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +86 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +41 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -9
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +143 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_logs.rb} +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +16 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +69 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -13
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +75 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/driver_finder.rb +43 -0
- data/lib/selenium/webdriver/common/element.rb +89 -29
- data/lib/selenium/webdriver/common/error.rb +32 -198
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -22
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +10 -6
- data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
- data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
- data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +71 -82
- data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
- data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
- data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
- data/lib/selenium/webdriver/common/interactions/scroll.rb +59 -0
- data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
- data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
- data/lib/selenium/webdriver/common/{w3c_manager.rb → interactions/wheel_input.rb} +14 -17
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/local_driver.rb +55 -0
- data/lib/selenium/webdriver/common/log_entry.rb +2 -2
- data/lib/selenium/webdriver/common/logger.rb +58 -15
- data/lib/selenium/webdriver/common/manager.rb +11 -38
- data/lib/selenium/webdriver/common/options.rb +169 -23
- data/lib/selenium/webdriver/common/platform.rb +14 -6
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
- data/lib/selenium/webdriver/common/proxy.rb +7 -4
- data/lib/selenium/webdriver/common/search_context.rb +7 -9
- data/lib/selenium/webdriver/common/selenium_manager.rb +108 -0
- data/lib/selenium/webdriver/common/service.rb +17 -136
- data/lib/selenium/webdriver/common/service_manager.rb +142 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +86 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +4 -4
- data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
- data/lib/selenium/webdriver/common/takes_screenshot.rb +65 -0
- data/lib/selenium/webdriver/common/target_locator.rb +31 -4
- data/lib/selenium/webdriver/common/timeouts.rb +31 -4
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +164 -0
- data/lib/selenium/webdriver/common/window.rb +6 -10
- data/lib/selenium/webdriver/common/zipper.rb +4 -10
- data/lib/selenium/webdriver/common.rb +42 -18
- data/lib/selenium/webdriver/devtools/console_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +34 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +35 -0
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +57 -0
- data/lib/selenium/webdriver/devtools/request.rb +65 -0
- data/lib/selenium/webdriver/devtools/response.rb +64 -0
- data/lib/selenium/webdriver/devtools.rb +96 -0
- data/lib/selenium/webdriver/edge/driver.rb +11 -27
- data/lib/selenium/webdriver/edge/features.rb +44 -0
- data/lib/selenium/webdriver/edge/options.rb +10 -49
- data/lib/selenium/webdriver/edge/profile.rb +33 -0
- data/lib/selenium/webdriver/edge/service.rb +7 -27
- data/lib/selenium/webdriver/edge.rb +11 -14
- data/lib/selenium/webdriver/firefox/driver.rb +38 -19
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/features.rb +66 -0
- data/lib/selenium/webdriver/firefox/options.rb +77 -50
- data/lib/selenium/webdriver/firefox/profile.rb +16 -70
- data/lib/selenium/webdriver/firefox/service.rb +3 -13
- data/lib/selenium/webdriver/firefox/util.rb +1 -1
- data/lib/selenium/webdriver/firefox.rb +17 -28
- data/lib/selenium/webdriver/ie/driver.rb +5 -45
- data/lib/selenium/webdriver/ie/options.rb +15 -46
- data/lib/selenium/webdriver/ie/service.rb +11 -19
- data/lib/selenium/webdriver/ie.rb +3 -16
- data/lib/selenium/webdriver/remote/bridge/commands.rb +170 -0
- data/lib/selenium/webdriver/remote/bridge.rb +590 -86
- data/lib/selenium/webdriver/remote/capabilities.rb +182 -124
- data/lib/selenium/webdriver/remote/driver.rb +30 -15
- data/lib/selenium/webdriver/remote/http/common.rb +0 -5
- data/lib/selenium/webdriver/remote/http/curb.rb +0 -2
- data/lib/selenium/webdriver/remote/http/default.rb +23 -31
- data/lib/selenium/webdriver/remote/response.rb +17 -49
- data/lib/selenium/webdriver/remote.rb +14 -12
- data/lib/selenium/webdriver/safari/driver.rb +7 -29
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -5
- data/lib/selenium/webdriver/safari/options.rb +12 -27
- data/lib/selenium/webdriver/safari/service.rb +3 -11
- data/lib/selenium/webdriver/safari.rb +14 -20
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/color.rb +22 -22
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/guards/guard.rb +87 -0
- data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +21 -20
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/relative_locator.rb +50 -0
- data/lib/selenium/webdriver/support/select.rb +6 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +17 -17
- data/selenium-webdriver.gemspec +36 -18
- metadata +164 -94
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/firefox/binary.rb +0 -187
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -60
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -20,7 +20,10 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
class Element
|
23
|
+
ELEMENT_KEY = 'element-6066-11e4-a52e-4f735466cecf'
|
24
|
+
|
23
25
|
include SearchContext
|
26
|
+
include TakesScreenshot
|
24
27
|
|
25
28
|
#
|
26
29
|
# Creates a new Element
|
@@ -40,10 +43,10 @@ module Selenium
|
|
40
43
|
def ==(other)
|
41
44
|
other.is_a?(self.class) && ref == other.ref
|
42
45
|
end
|
43
|
-
|
46
|
+
alias eql? ==
|
44
47
|
|
45
48
|
def hash
|
46
|
-
@id
|
49
|
+
[@id, @bridge].hash
|
47
50
|
end
|
48
51
|
|
49
52
|
#
|
@@ -89,13 +92,18 @@ module Selenium
|
|
89
92
|
end
|
90
93
|
|
91
94
|
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
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 semicolon.
|
105
|
+
#
|
106
|
+
# The following are deemed to be "boolean" attributes, and will return either "true" or "false":
|
99
107
|
#
|
100
108
|
# async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
|
101
109
|
# defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
|
@@ -103,29 +111,73 @@ module Selenium
|
|
103
111
|
# nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
104
112
|
# selected, spellcheck, truespeed, willvalidate
|
105
113
|
#
|
106
|
-
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as
|
107
|
-
# expected:
|
114
|
+
# Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:
|
108
115
|
#
|
109
|
-
# 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.
|
110
118
|
#
|
111
119
|
# @param [String] name attribute name
|
112
120
|
# @return [String, nil] attribute value
|
113
121
|
#
|
122
|
+
# @see #dom_attribute
|
123
|
+
# @see #property
|
124
|
+
#
|
114
125
|
|
115
126
|
def attribute(name)
|
116
127
|
bridge.element_attribute self, name
|
117
128
|
end
|
118
129
|
|
119
130
|
#
|
120
|
-
#
|
121
|
-
#
|
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.
|
122
154
|
#
|
123
155
|
# @param [String] name property name
|
124
156
|
# @return [String, nil] property value
|
125
157
|
#
|
126
158
|
|
127
159
|
def property(name)
|
128
|
-
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
|
129
181
|
end
|
130
182
|
|
131
183
|
#
|
@@ -155,7 +207,7 @@ module Selenium
|
|
155
207
|
def send_keys(*args)
|
156
208
|
bridge.send_keys_to_element @id, Keys.encode(args)
|
157
209
|
end
|
158
|
-
|
210
|
+
alias send_key send_keys
|
159
211
|
|
160
212
|
#
|
161
213
|
# If this element is a text entry element, this will clear the value. Has no effect on other
|
@@ -223,7 +275,7 @@ module Selenium
|
|
223
275
|
def css_value(prop)
|
224
276
|
bridge.element_value_of_css_property @id, prop
|
225
277
|
end
|
226
|
-
|
278
|
+
alias style css_value
|
227
279
|
|
228
280
|
#
|
229
281
|
# Get the location of this element.
|
@@ -265,33 +317,42 @@ module Selenium
|
|
265
317
|
bridge.element_size @id
|
266
318
|
end
|
267
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
|
+
|
268
330
|
#-------------------------------- sugar --------------------------------
|
269
331
|
|
270
332
|
#
|
271
333
|
# element.first(id: 'foo')
|
272
334
|
#
|
273
335
|
|
274
|
-
|
336
|
+
alias first find_element
|
275
337
|
|
276
338
|
#
|
277
339
|
# element.all(class: 'bar')
|
278
340
|
#
|
279
341
|
|
280
|
-
|
342
|
+
alias all find_elements
|
281
343
|
|
282
344
|
#
|
283
345
|
# element['class'] or element[:class] #=> "someclass"
|
284
346
|
#
|
285
|
-
|
347
|
+
alias [] attribute
|
286
348
|
|
287
|
-
#
|
288
|
-
# for SearchContext and execute_script
|
289
349
|
#
|
290
350
|
# @api private
|
351
|
+
# @see SearchContext
|
291
352
|
#
|
292
353
|
|
293
354
|
def ref
|
294
|
-
@id
|
355
|
+
[:element, @id]
|
295
356
|
end
|
296
357
|
|
297
358
|
#
|
@@ -312,12 +373,7 @@ module Selenium
|
|
312
373
|
#
|
313
374
|
|
314
375
|
def as_json(*)
|
315
|
-
|
316
|
-
'element-6066-11e4-a52e-4f735466cecf'
|
317
|
-
else
|
318
|
-
'ELEMENT'
|
319
|
-
end
|
320
|
-
@id.is_a?(Hash) ? @id : {key => @id}
|
376
|
+
@id.is_a?(Hash) ? @id : {ELEMENT_KEY => @id}
|
321
377
|
end
|
322
378
|
|
323
379
|
private
|
@@ -330,6 +386,10 @@ module Selenium
|
|
330
386
|
|
331
387
|
tn == 'option' || (tn == 'input' && %w[radio checkbox].include?(type))
|
332
388
|
end
|
389
|
+
|
390
|
+
def screenshot
|
391
|
+
bridge.element_screenshot(@id)
|
392
|
+
end
|
333
393
|
end # Element
|
334
394
|
end # WebDriver
|
335
395
|
end # Selenium
|
@@ -19,191 +19,133 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
module Error
|
23
|
-
|
22
|
+
module Error
|
24
23
|
#
|
25
|
-
# Returns exception from
|
26
|
-
# @param [
|
24
|
+
# Returns exception from its string representation.
|
25
|
+
# @param [String, nil] error
|
27
26
|
#
|
28
27
|
|
29
|
-
def self.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
when String
|
36
|
-
klass_name = code.split(' ').map(&:capitalize).join.sub(/Error$/, '')
|
37
|
-
const_get("#{klass_name}Error", false)
|
38
|
-
end
|
39
|
-
rescue KeyError, NameError
|
28
|
+
def self.for_error(error)
|
29
|
+
return if error.nil?
|
30
|
+
|
31
|
+
klass_name = error.split.map(&:capitalize).join.sub(/Error$/, '')
|
32
|
+
const_get("#{klass_name}Error", false)
|
33
|
+
rescue NameError
|
40
34
|
WebDriverError
|
41
35
|
end
|
42
36
|
|
43
37
|
class WebDriverError < StandardError; end
|
44
38
|
|
45
|
-
class IndexOutOfBoundsError < WebDriverError; end # 1
|
46
|
-
class NoCollectionError < WebDriverError; end # 2
|
47
|
-
class NoStringError < WebDriverError; end # 3
|
48
|
-
class NoStringLengthError < WebDriverError; end # 4
|
49
|
-
class NoStringWrapperError < WebDriverError; end # 5
|
50
|
-
class NoSuchDriverError < WebDriverError; end # 6
|
51
|
-
|
52
39
|
#
|
53
40
|
# An element could not be located on the page using the given search parameters.
|
54
41
|
#
|
55
42
|
|
56
|
-
class NoSuchElementError < WebDriverError; end
|
43
|
+
class NoSuchElementError < WebDriverError; end
|
57
44
|
|
58
45
|
#
|
59
46
|
# A command to switch to a frame could not be satisfied because the frame could not be found.
|
60
47
|
#
|
61
48
|
|
62
|
-
class NoSuchFrameError < WebDriverError; end
|
49
|
+
class NoSuchFrameError < WebDriverError; end
|
63
50
|
|
64
51
|
#
|
65
52
|
# A command could not be executed because the remote end is not aware of it.
|
66
53
|
#
|
67
54
|
|
68
|
-
class UnknownCommandError < WebDriverError; end
|
55
|
+
class UnknownCommandError < WebDriverError; end
|
69
56
|
|
70
57
|
#
|
71
58
|
# A command failed because the referenced element is no longer attached to the DOM.
|
72
59
|
#
|
73
60
|
|
74
|
-
class StaleElementReferenceError < WebDriverError; end
|
61
|
+
class StaleElementReferenceError < WebDriverError; end
|
75
62
|
|
76
63
|
#
|
77
|
-
#
|
78
|
-
# so is not able to be interacted with.
|
64
|
+
# A command failed because the referenced shadow root is no longer attached to the DOM.
|
79
65
|
#
|
80
66
|
|
81
|
-
class
|
67
|
+
class DetachedShadowRootError < WebDriverError; end
|
82
68
|
|
83
69
|
#
|
84
70
|
# The target element is in an invalid state, rendering it impossible to interact with, for
|
85
71
|
# example if you click a disabled element.
|
86
72
|
#
|
87
73
|
|
88
|
-
class InvalidElementStateError < WebDriverError; end
|
74
|
+
class InvalidElementStateError < WebDriverError; end
|
89
75
|
|
90
76
|
#
|
91
77
|
# An unknown error occurred in the remote end while processing the command.
|
92
78
|
#
|
93
79
|
|
94
|
-
class UnknownError < WebDriverError; end
|
95
|
-
class ExpectedError < WebDriverError; end # 14
|
80
|
+
class UnknownError < WebDriverError; end
|
96
81
|
|
97
82
|
#
|
98
|
-
# An
|
83
|
+
# An error occurred while executing JavaScript supplied by the user.
|
99
84
|
#
|
100
85
|
|
101
|
-
class
|
102
|
-
class NoSuchDocumentError < WebDriverError; end # 16
|
86
|
+
class JavascriptError < WebDriverError; end
|
103
87
|
|
104
88
|
#
|
105
|
-
# An
|
89
|
+
# An operation did not complete before its timeout expired.
|
106
90
|
#
|
107
91
|
|
108
|
-
class
|
109
|
-
class NoScriptResultError < WebDriverError; end # 18
|
92
|
+
class TimeoutError < WebDriverError; end
|
110
93
|
|
111
94
|
#
|
112
|
-
#
|
95
|
+
# A command to switch to a window could not be satisfied because
|
96
|
+
# the window could not be found.
|
113
97
|
#
|
114
98
|
|
115
|
-
class
|
116
|
-
class NoSuchCollectionError < WebDriverError; end # 20
|
99
|
+
class NoSuchWindowError < WebDriverError; end
|
117
100
|
|
118
101
|
#
|
119
|
-
#
|
102
|
+
# The element does not have a shadow root.
|
120
103
|
#
|
121
104
|
|
122
|
-
class
|
123
|
-
|
124
|
-
class NullPointerError < WebDriverError; end # 22
|
125
|
-
class NoSuchWindowError < WebDriverError; end # 23
|
105
|
+
class NoSuchShadowRootError < WebDriverError; end
|
126
106
|
|
127
107
|
#
|
128
108
|
# An illegal attempt was made to set a cookie under a different domain than the current page.
|
129
109
|
#
|
130
110
|
|
131
|
-
class InvalidCookieDomainError < WebDriverError; end
|
111
|
+
class InvalidCookieDomainError < WebDriverError; end
|
132
112
|
|
133
113
|
#
|
134
114
|
# A command to set a cookie's value could not be satisfied.
|
135
115
|
#
|
136
116
|
|
137
|
-
class UnableToSetCookieError < WebDriverError; end
|
138
|
-
|
139
|
-
#
|
140
|
-
# Raised when an alert dialog is present that has not been dealt with.
|
141
|
-
#
|
142
|
-
class UnhandledAlertError < WebDriverError; end # 26
|
117
|
+
class UnableToSetCookieError < WebDriverError; end
|
143
118
|
|
144
119
|
#
|
145
120
|
# An attempt was made to operate on a modal dialog when one was not open:
|
146
121
|
#
|
147
|
-
# * W3C dialect is NoSuchAlertError
|
148
|
-
# * OSS dialect is NoAlertPresentError
|
149
|
-
#
|
150
|
-
# We want to allow clients to rescue NoSuchAlertError as a superclass for
|
151
|
-
# dialect-agnostic implementation, so NoAlertPresentError should inherit from it.
|
152
|
-
#
|
153
122
|
|
154
123
|
class NoSuchAlertError < WebDriverError; end
|
155
|
-
class NoAlertPresentError < NoSuchAlertError; end # 27
|
156
124
|
|
157
125
|
#
|
158
126
|
# A script did not complete before its timeout expired.
|
159
127
|
#
|
160
128
|
|
161
|
-
class
|
162
|
-
|
163
|
-
#
|
164
|
-
# The coordinates provided to an interactions operation are invalid.
|
165
|
-
#
|
166
|
-
|
167
|
-
class InvalidElementCoordinatesError < WebDriverError; end # 29
|
168
|
-
|
169
|
-
#
|
170
|
-
# Indicates that IME support is not available. This exception is rasied for every IME-related
|
171
|
-
# method call if IME support is not available on the machine.
|
172
|
-
#
|
173
|
-
|
174
|
-
class IMENotAvailableError < WebDriverError; end # 30
|
175
|
-
|
176
|
-
#
|
177
|
-
# Indicates that activating an IME engine has failed.
|
178
|
-
#
|
179
|
-
|
180
|
-
class IMEEngineActivationFailedError < WebDriverError; end # 31
|
129
|
+
class ScriptTimeoutError < WebDriverError; end
|
181
130
|
|
182
131
|
#
|
183
132
|
# Argument was an invalid selector.
|
184
133
|
#
|
185
134
|
|
186
|
-
class InvalidSelectorError < WebDriverError; end
|
135
|
+
class InvalidSelectorError < WebDriverError; end
|
187
136
|
|
188
137
|
#
|
189
138
|
# A new session could not be created.
|
190
139
|
#
|
191
140
|
|
192
|
-
class SessionNotCreatedError < WebDriverError; end
|
141
|
+
class SessionNotCreatedError < WebDriverError; end
|
193
142
|
|
194
143
|
#
|
195
144
|
# The target for mouse interaction is not in the browser's viewport and cannot be brought
|
196
145
|
# into that viewport.
|
197
146
|
#
|
198
147
|
|
199
|
-
class MoveTargetOutOfBoundsError < WebDriverError; end
|
200
|
-
|
201
|
-
#
|
202
|
-
# Indicates that the XPath selector is invalid
|
203
|
-
#
|
204
|
-
|
205
|
-
class InvalidXpathSelectorError < WebDriverError; end
|
206
|
-
class InvalidXpathSelectorReturnTyperError < WebDriverError; end
|
148
|
+
class MoveTargetOutOfBoundsError < WebDriverError; end
|
207
149
|
|
208
150
|
#
|
209
151
|
# A command could not be completed because the element is not pointer or keyboard
|
@@ -270,114 +212,6 @@ module Selenium
|
|
270
212
|
#
|
271
213
|
|
272
214
|
class UnsupportedOperationError < WebDriverError; end
|
273
|
-
|
274
|
-
# Aliases for OSS dialect.
|
275
|
-
ScriptTimeoutError = Class.new(ScriptTimeOutError)
|
276
|
-
TimeoutError = Class.new(TimeOutError)
|
277
|
-
NoAlertOpenError = Class.new(NoAlertPresentError)
|
278
|
-
|
279
|
-
# Aliases for backwards compatibility.
|
280
|
-
ObsoleteElementError = Class.new(StaleElementReferenceError)
|
281
|
-
UnhandledError = Class.new(UnknownError)
|
282
|
-
UnexpectedJavascriptError = Class.new(JavascriptError)
|
283
|
-
ElementNotDisplayedError = Class.new(ElementNotVisibleError)
|
284
|
-
|
285
|
-
#
|
286
|
-
# @api private
|
287
|
-
#
|
288
|
-
|
289
|
-
ERRORS = {
|
290
|
-
1 => IndexOutOfBoundsError,
|
291
|
-
2 => NoCollectionError,
|
292
|
-
3 => NoStringError,
|
293
|
-
4 => NoStringLengthError,
|
294
|
-
5 => NoStringWrapperError,
|
295
|
-
6 => NoSuchDriverError,
|
296
|
-
7 => NoSuchElementError,
|
297
|
-
8 => NoSuchFrameError,
|
298
|
-
9 => UnknownCommandError,
|
299
|
-
10 => StaleElementReferenceError,
|
300
|
-
11 => ElementNotVisibleError,
|
301
|
-
12 => InvalidElementStateError,
|
302
|
-
13 => UnknownError,
|
303
|
-
14 => ExpectedError,
|
304
|
-
15 => ElementNotSelectableError,
|
305
|
-
16 => NoSuchDocumentError,
|
306
|
-
17 => JavascriptError,
|
307
|
-
18 => NoScriptResultError,
|
308
|
-
19 => XPathLookupError,
|
309
|
-
20 => NoSuchCollectionError,
|
310
|
-
21 => TimeOutError,
|
311
|
-
22 => NullPointerError,
|
312
|
-
23 => NoSuchWindowError,
|
313
|
-
24 => InvalidCookieDomainError,
|
314
|
-
25 => UnableToSetCookieError,
|
315
|
-
26 => UnhandledAlertError,
|
316
|
-
27 => NoAlertPresentError,
|
317
|
-
28 => ScriptTimeOutError,
|
318
|
-
29 => InvalidElementCoordinatesError,
|
319
|
-
30 => IMENotAvailableError,
|
320
|
-
31 => IMEEngineActivationFailedError,
|
321
|
-
32 => InvalidSelectorError,
|
322
|
-
33 => SessionNotCreatedError,
|
323
|
-
34 => MoveTargetOutOfBoundsError,
|
324
|
-
# The following are W3C-specific errors,
|
325
|
-
# they don't really need error codes, we just make them up!
|
326
|
-
51 => InvalidXpathSelectorError,
|
327
|
-
52 => InvalidXpathSelectorReturnTyperError,
|
328
|
-
60 => ElementNotInteractableError,
|
329
|
-
61 => InvalidArgumentError,
|
330
|
-
62 => NoSuchCookieError,
|
331
|
-
63 => UnableToCaptureScreenError
|
332
|
-
}.freeze
|
333
|
-
|
334
|
-
DEPRECATED_ERRORS = {
|
335
|
-
IndexOutOfBoundsError: nil,
|
336
|
-
NoCollectionError: nil,
|
337
|
-
NoStringError: nil,
|
338
|
-
NoStringLengthError: nil,
|
339
|
-
NoStringWrapperError: nil,
|
340
|
-
NoSuchDriverError: nil,
|
341
|
-
ElementNotVisibleError: ElementNotInteractableError,
|
342
|
-
InvalidElementStateError: ElementNotInteractableError,
|
343
|
-
ElementNotSelectableError: ElementNotInteractableError,
|
344
|
-
ExpectedError: nil,
|
345
|
-
NoSuchDocumentError: nil,
|
346
|
-
NoScriptResultError: nil,
|
347
|
-
XPathLookupError: InvalidSelectorError,
|
348
|
-
NoSuchCollectionError: nil,
|
349
|
-
UnhandledAlertError: UnexpectedAlertOpenError,
|
350
|
-
NoAlertPresentError: NoSuchAlertError,
|
351
|
-
NoAlertOpenError: NoSuchAlertError,
|
352
|
-
ScriptTimeOutError: ScriptTimeoutError,
|
353
|
-
InvalidElementCoordinatesError: nil,
|
354
|
-
IMENotAvailableError: nil,
|
355
|
-
IMEEngineActivationFailedError: nil,
|
356
|
-
InvalidXpathSelectorError: InvalidSelectorError,
|
357
|
-
InvalidXpathSelectorReturnTyperError: InvalidSelectorError,
|
358
|
-
TimeOutError: TimeoutError,
|
359
|
-
ObsoleteElementError: StaleElementReferenceError,
|
360
|
-
UnhandledError: UnknownError,
|
361
|
-
UnexpectedJavascriptError: JavascriptError,
|
362
|
-
ElementNotDisplayedError: ElementNotInteractableError
|
363
|
-
}.freeze
|
364
|
-
|
365
|
-
DEPRECATED_ERRORS.keys.each do |oss_error|
|
366
|
-
remove_const oss_error
|
367
|
-
end
|
368
|
-
|
369
|
-
def self.const_missing(const_name)
|
370
|
-
super unless DEPRECATED_ERRORS.key?(const_name)
|
371
|
-
if DEPRECATED_ERRORS[const_name]
|
372
|
-
WebDriver.logger.deprecate("Selenium::WebDriver::Error::#{const_name}",
|
373
|
-
"#{DEPRECATED_ERRORS[const_name]} (ensure the driver supports W3C WebDriver specification)")
|
374
|
-
DEPRECATED_ERRORS[const_name]
|
375
|
-
else
|
376
|
-
WebDriver.logger.deprecate("Selenium::WebDriver::Error::#{const_name}")
|
377
|
-
WebDriverError
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
215
|
end # Error
|
382
216
|
end # WebDriver
|
383
217
|
end # Selenium
|
@@ -22,8 +22,15 @@ require 'securerandom'
|
|
22
22
|
module Selenium
|
23
23
|
module WebDriver
|
24
24
|
module Interactions
|
25
|
+
#
|
26
|
+
# Superclass for the input device sources
|
27
|
+
# Manages Array of Interaction instances for the device
|
28
|
+
#
|
29
|
+
# @api private
|
30
|
+
#
|
31
|
+
|
25
32
|
class InputDevice
|
26
|
-
attr_reader :name, :actions
|
33
|
+
attr_reader :name, :actions, :type
|
27
34
|
|
28
35
|
def initialize(name = nil)
|
29
36
|
@name = name || SecureRandom.uuid
|
@@ -44,9 +51,8 @@ module Selenium
|
|
44
51
|
add_action(Pause.new(self, duration))
|
45
52
|
end
|
46
53
|
|
47
|
-
def
|
48
|
-
actions
|
49
|
-
actions.empty?
|
54
|
+
def encode
|
55
|
+
{type: type, id: name, actions: @actions.map(&:encode)} unless @actions.empty?
|
50
56
|
end
|
51
57
|
end # InputDevice
|
52
58
|
end # Interactions
|
@@ -20,34 +20,24 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Interactions
|
23
|
-
|
24
|
-
|
23
|
+
#
|
24
|
+
# Superclass for classes defining actions
|
25
|
+
# Do not initialize directly, only use subclass
|
26
|
+
#
|
27
|
+
# @api private
|
28
|
+
#
|
25
29
|
|
26
|
-
|
30
|
+
class Interaction
|
31
|
+
attr_reader :type
|
27
32
|
|
28
33
|
def initialize(source)
|
29
|
-
|
30
|
-
|
31
|
-
@source = source
|
34
|
+
assert_source(source)
|
32
35
|
end
|
33
|
-
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
super(source)
|
38
|
-
@duration = duration
|
37
|
+
def assert_source(_source)
|
38
|
+
raise NotImplementedError, 'subclass responsibility'
|
39
39
|
end
|
40
|
-
|
41
|
-
def type
|
42
|
-
PAUSE
|
43
|
-
end
|
44
|
-
|
45
|
-
def encode
|
46
|
-
output = {type: type}
|
47
|
-
output[:duration] = (@duration * 1000).to_i if @duration
|
48
|
-
output
|
49
|
-
end
|
50
|
-
end # Interaction
|
40
|
+
end
|
51
41
|
end # Interactions
|
52
42
|
end # WebDriver
|
53
43
|
end # Selenium
|
@@ -23,20 +23,40 @@ module Selenium
|
|
23
23
|
KEY = :key
|
24
24
|
POINTER = :pointer
|
25
25
|
NONE = :none
|
26
|
-
|
26
|
+
WHEEL = :wheel
|
27
|
+
|
28
|
+
#
|
29
|
+
# Class methods for initializing known Input devices
|
30
|
+
#
|
27
31
|
|
28
32
|
class << self
|
29
|
-
def key(name)
|
33
|
+
def key(name = nil)
|
30
34
|
KeyInput.new(name)
|
31
35
|
end
|
32
36
|
|
33
|
-
def pointer(kind,
|
34
|
-
PointerInput.new(kind,
|
37
|
+
def pointer(kind = :mouse, name: nil)
|
38
|
+
PointerInput.new(kind, name: name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def mouse(name: nil)
|
42
|
+
pointer(name: name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def pen(name: nil)
|
46
|
+
pointer(:pen, name: name)
|
47
|
+
end
|
48
|
+
|
49
|
+
def touch(name: nil)
|
50
|
+
pointer(:touch, name: name)
|
35
51
|
end
|
36
52
|
|
37
53
|
def none(name = nil)
|
38
54
|
NoneInput.new(name)
|
39
55
|
end
|
56
|
+
|
57
|
+
def wheel(name = nil)
|
58
|
+
WheelInput.new(name)
|
59
|
+
end
|
40
60
|
end
|
41
61
|
end # Interactions
|
42
62
|
end # WebDriver
|