selenium-webdriver 4.50.0 → 4.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +22 -0
- data/Gemfile +14 -0
- data/README.md +20 -0
- data/bin/linux-arm64/selenium-manager +0 -0
- data/bin/linux-x86_64/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +544 -227
- data/bin/selenium-manager.cdx.json +810 -728
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/webdriver/atoms/findElements.js +961 -248
- data/lib/selenium/webdriver/atoms/getAttribute.js +154 -125
- data/lib/selenium/webdriver/atoms/isDisplayed.js +434 -362
- data/lib/selenium/webdriver/atoms.rb +4 -1
- data/lib/selenium/webdriver/bidi/protocol/bluetooth.rb +6 -6
- data/lib/selenium/webdriver/bidi/protocol/browser.rb +21 -9
- data/lib/selenium/webdriver/bidi/protocol/browsing_context.rb +109 -39
- data/lib/selenium/webdriver/bidi/protocol/emulation.rb +89 -44
- data/lib/selenium/webdriver/bidi/protocol/input.rb +95 -31
- data/lib/selenium/webdriver/bidi/protocol/log.rb +4 -4
- data/lib/selenium/webdriver/bidi/protocol/moz_debugging.rb +12 -10
- data/lib/selenium/webdriver/bidi/protocol/moz_profiler.rb +4 -4
- data/lib/selenium/webdriver/bidi/protocol/network.rb +82 -39
- data/lib/selenium/webdriver/bidi/protocol/script.rb +39 -25
- data/lib/selenium/webdriver/bidi/protocol/session.rb +82 -28
- data/lib/selenium/webdriver/bidi/protocol/storage.rb +3 -3
- data/lib/selenium/webdriver/bidi/protocol/user_agent_client_hints.rb +3 -3
- data/lib/selenium/webdriver/bidi/protocol/web_extension.rb +17 -9
- data/lib/selenium/webdriver/bidi/serialization/record.rb +92 -17
- data/lib/selenium/webdriver/bidi/serialization.rb +2 -2
- data/lib/selenium/webdriver/bidi/support/bidi_generate.rb +241 -143
- data/lib/selenium/webdriver/common/client_config.rb +4 -1
- data/lib/selenium/webdriver/common/driver_finder.rb +5 -2
- data/lib/selenium/webdriver/common/websocket_connection.rb +51 -13
- data/lib/selenium/webdriver/remote/http/default.rb +17 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- data/selenium-webdriver.gemspec +0 -12
- metadata +6 -163
|
@@ -32,8 +32,7 @@ module Selenium
|
|
|
32
32
|
# @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
|
|
33
33
|
# @see https://w3c.github.io/webdriver-bidi/#cddl-type-webextensioninstallparameters
|
|
34
34
|
InstallParameters = Serialization::Record.define(
|
|
35
|
-
extension_data: {wire_key: 'extensionData', ref: 'WebExtension::ExtensionData'}
|
|
36
|
-
extensible: true
|
|
35
|
+
extension_data: {wire_key: 'extensionData', ref: 'WebExtension::ExtensionData'}
|
|
37
36
|
)
|
|
38
37
|
|
|
39
38
|
# @api private
|
|
@@ -99,7 +98,7 @@ module Selenium
|
|
|
99
98
|
id: {wire_key: 'id', primitive: 'string'},
|
|
100
99
|
name: {wire_key: 'name', primitive: 'string'},
|
|
101
100
|
version: {wire_key: 'version', primitive: 'string'},
|
|
102
|
-
manifest_version: {wire_key: 'manifestVersion', primitive: 'integer'},
|
|
101
|
+
manifest_version: {wire_key: 'manifestVersion', primitive: 'integer', min: 0, max: 9_007_199_254_740_991},
|
|
103
102
|
is_active: {wire_key: 'isActive', primitive: 'boolean'},
|
|
104
103
|
is_system: {wire_key: 'isSystem', primitive: 'boolean'},
|
|
105
104
|
hidden: {wire_key: 'hidden', primitive: 'boolean'},
|
|
@@ -114,7 +113,7 @@ module Selenium
|
|
|
114
113
|
uuid: {wire_key: 'uuid', primitive: 'string'},
|
|
115
114
|
base_url: {wire_key: 'baseURL', primitive: 'string'},
|
|
116
115
|
extension_url: {wire_key: 'extensionURL', primitive: 'string'},
|
|
117
|
-
background_scripts: {wire_key: 'backgroundScripts', list: true}
|
|
116
|
+
background_scripts: {wire_key: 'backgroundScripts', list: true, primitive: 'string'}
|
|
118
117
|
)
|
|
119
118
|
|
|
120
119
|
def extension_data = ExtensionData
|
|
@@ -143,15 +142,24 @@ module Selenium
|
|
|
143
142
|
# moz: vendor variant of WebExtension, with browser-specific commands and params.
|
|
144
143
|
# Construct Moz.new(source) for a matching session; other sessions use WebExtension.
|
|
145
144
|
class Moz < WebExtension
|
|
145
|
+
# @api private
|
|
146
|
+
# @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
|
|
147
|
+
# @see https://w3c.github.io/webdriver-bidi/#cddl-type-webextensioninstallparameters
|
|
148
|
+
InstallParameters = Serialization::Record.define(
|
|
149
|
+
extension_data: {wire_key: 'extensionData', ref: 'WebExtension::ExtensionData'},
|
|
150
|
+
allow_private_browsing: {wire_key: 'moz:allowPrivateBrowsing', required: false, primitive: 'boolean'},
|
|
151
|
+
permanent: {wire_key: 'moz:permanent', required: false, primitive: 'boolean'}
|
|
152
|
+
)
|
|
153
|
+
|
|
146
154
|
# @api private
|
|
147
155
|
# @see https://www.selenium.dev/documentation/warnings/bidi-implementation/
|
|
148
156
|
# @see https://w3c.github.io/webdriver-bidi/#command-webExtension-install
|
|
149
157
|
def install(extension_data:, allow_private_browsing: Serialization::UNSET, permanent: Serialization::UNSET)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
params = InstallParameters.new(
|
|
159
|
+
extension_data: extension_data,
|
|
160
|
+
allow_private_browsing: allow_private_browsing,
|
|
161
|
+
permanent: permanent
|
|
162
|
+
)
|
|
155
163
|
execute(cmd: 'webExtension.install', params: params, result: WebExtension::InstallResult)
|
|
156
164
|
end
|
|
157
165
|
|
|
@@ -30,7 +30,7 @@ module Selenium
|
|
|
30
30
|
class Record < ::Data
|
|
31
31
|
# Named Field, not Member, to avoid colliding with +::Data#members+.
|
|
32
32
|
Field = ::Data.define(:name, :wire_key, :nullable, :ref, :list, :fixed, :enum, :required, :primitive,
|
|
33
|
-
:scalar, :const)
|
|
33
|
+
:scalar, :const, :map, :min, :max, :exclusive_min, :exclusive_max)
|
|
34
34
|
|
|
35
35
|
def self.define(**spec)
|
|
36
36
|
extensible = spec.delete(:extensible) || false
|
|
@@ -61,7 +61,9 @@ module Selenium
|
|
|
61
61
|
nullable: meta[:nullable] || false, ref: meta[:ref],
|
|
62
62
|
list: meta[:list] || false, fixed: meta.fetch(:fixed, UNSET), enum: meta[:enum],
|
|
63
63
|
required: meta.fetch(:required, true), primitive: meta[:primitive],
|
|
64
|
-
scalar: meta[:scalar], const: meta.fetch(:const, UNSET)
|
|
64
|
+
scalar: meta[:scalar], const: meta.fetch(:const, UNSET), map: meta[:map],
|
|
65
|
+
min: meta[:min], max: meta[:max], exclusive_min: meta[:exclusive_min] || false,
|
|
66
|
+
exclusive_max: meta[:exclusive_max] || false)
|
|
65
67
|
end
|
|
66
68
|
private_class_method :field
|
|
67
69
|
|
|
@@ -121,12 +123,13 @@ module Selenium
|
|
|
121
123
|
end
|
|
122
124
|
|
|
123
125
|
# Checks a field that carries an actual value (neither omitted nor nil): a nullable-const
|
|
124
|
-
# field against its literal, list/scalar shape, primitive type (
|
|
125
|
-
#
|
|
126
|
+
# field against its literal, list/scalar shape, primitive type (per element for a list), ref
|
|
127
|
+
# type, and enum membership (resolved lazily so a cross-domain enum need not load first).
|
|
126
128
|
def validate_present(field, value)
|
|
127
129
|
validate_const(field, value)
|
|
128
130
|
check_outbound_shape(field, value)
|
|
129
|
-
check_outbound_primitive(field, value)
|
|
131
|
+
check_outbound_primitive(field, value)
|
|
132
|
+
check_outbound_map(field, value) if field.map
|
|
130
133
|
validate_ref(field, value) if field.ref
|
|
131
134
|
Serialization.validate!("#{name}##{field.name}", value, Protocol.const_get(field.enum)) if field.enum
|
|
132
135
|
end
|
|
@@ -200,14 +203,19 @@ module Selenium
|
|
|
200
203
|
end
|
|
201
204
|
|
|
202
205
|
# Outbound mirror of check_primitive: a primitive-typed arg (`string`/`integer`/…) must be
|
|
203
|
-
# the matching Ruby type, so a caller mistake (a string width, a
|
|
204
|
-
# ArgumentError here rather than a rejection the browser reports a
|
|
205
|
-
# with no primitive descriptor (enum, ref, opaque) passes
|
|
206
|
+
# the matching Ruby type within its declared bounds, so a caller mistake (a string width, a
|
|
207
|
+
# zero count) is a local ArgumentError here rather than a rejection the browser reports a
|
|
208
|
+
# round-trip later. A field with no primitive descriptor (enum, ref, opaque) passes.
|
|
206
209
|
def check_outbound_primitive(field, value)
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
mismatch = primitive_mismatch(field, value)
|
|
211
|
+
raise ::ArgumentError, "#{name}##{field.name}#{mismatch}" if mismatch
|
|
212
|
+
end
|
|
209
213
|
|
|
210
|
-
|
|
214
|
+
# Outbound mirror of check_map: a map-typed arg must be a Hash whose values are the
|
|
215
|
+
# declared primitive, so a caller mistake is a local ArgumentError.
|
|
216
|
+
def check_outbound_map(field, value)
|
|
217
|
+
mismatch = map_mismatch(field, value)
|
|
218
|
+
raise ::ArgumentError, "#{name}##{field.name}#{mismatch}" if mismatch
|
|
211
219
|
end
|
|
212
220
|
|
|
213
221
|
def fixed?(field)
|
|
@@ -235,16 +243,20 @@ module Selenium
|
|
|
235
243
|
return Serialization.to_symbol("#{name}##{field.name}", raw, enum_hash(field)) if field.enum
|
|
236
244
|
|
|
237
245
|
if field.ref.nil?
|
|
238
|
-
return raw if field.
|
|
246
|
+
return check_map(field, raw) if field.map
|
|
239
247
|
|
|
240
248
|
check_primitive(field, raw)
|
|
241
|
-
|
|
242
|
-
return field.primitive == 'integer' && raw.is_a?(::Float) ? raw.to_i : raw
|
|
249
|
+
return field.list ? raw.map { |element| hold_integer(field, element) } : hold_integer(field, raw)
|
|
243
250
|
end
|
|
244
251
|
|
|
245
252
|
read_ref(field, raw)
|
|
246
253
|
end
|
|
247
254
|
|
|
255
|
+
# A whole number is exact in both types, so the declared type is held with nothing lost.
|
|
256
|
+
def hold_integer(field, value)
|
|
257
|
+
WHOLE_FLOAT.call(value) && Array(field.primitive).include?('integer') ? value.to_i : value
|
|
258
|
+
end
|
|
259
|
+
|
|
248
260
|
# Reads a ref-typed value into its class. A `scalar` position is an inline union with
|
|
249
261
|
# a scalar arm collapsed onto its union ref (a map's string keys): a non-object leaf
|
|
250
262
|
# passes through instead of being handed to the object_only union, but only when it
|
|
@@ -279,10 +291,73 @@ module Selenium
|
|
|
279
291
|
}.freeze
|
|
280
292
|
|
|
281
293
|
def check_primitive(field, raw)
|
|
282
|
-
|
|
283
|
-
|
|
294
|
+
mismatch = primitive_mismatch(field, raw)
|
|
295
|
+
raise Error::SerializationError, "#{name}##{field.name}#{mismatch}" if mismatch
|
|
296
|
+
end
|
|
284
297
|
|
|
285
|
-
|
|
298
|
+
# The suffix of the error a primitive-typed value earns, or nil when it conforms — shared by
|
|
299
|
+
# both directions like map_mismatch. A list checks each element, so a nil element mismatches.
|
|
300
|
+
def primitive_mismatch(field, value)
|
|
301
|
+
return if field.primitive.nil?
|
|
302
|
+
return element_mismatch(field, field.primitive, value) unless field.list
|
|
303
|
+
|
|
304
|
+
value.each_with_index do |element, index|
|
|
305
|
+
mismatch = element_mismatch(field, field.primitive, element)
|
|
306
|
+
return "[#{index}]#{mismatch}" if mismatch
|
|
307
|
+
end
|
|
308
|
+
nil
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# The field's bounds hold every numeric value it carries: the scalar, each list element, each map value.
|
|
312
|
+
def element_mismatch(field, primitives, value)
|
|
313
|
+
checks = Array(primitives).filter_map { |primitive| PRIMITIVE_CHECKS[primitive] }
|
|
314
|
+
return bound_mismatch(field, value) if checks.empty? || checks.any? { |check| check.call(value) }
|
|
315
|
+
|
|
316
|
+
" expected #{Array(primitives).join(' or ')}, got #{value.inspect}"
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def bound_mismatch(field, value)
|
|
320
|
+
return unless value.is_a?(::Numeric)
|
|
321
|
+
|
|
322
|
+
bound = violated_min(field, value) || violated_max(field, value)
|
|
323
|
+
" expected #{bound}, got #{value.inspect}" if bound
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
# Each is written as the in-bounds test, so NaN (in no range) fails rather than slipping past both sides.
|
|
327
|
+
def violated_min(field, value)
|
|
328
|
+
return if field.min.nil? || (field.exclusive_min ? value > field.min : value >= field.min)
|
|
329
|
+
|
|
330
|
+
"#{field.exclusive_min ? '>' : '>='} #{field.min}"
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def violated_max(field, value)
|
|
334
|
+
return if field.max.nil? || (field.exclusive_max ? value < field.max : value <= field.max)
|
|
335
|
+
|
|
336
|
+
"#{field.exclusive_max ? '<' : '<='} #{field.max}"
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# A `map` field (`{*text => <primitive>}`, e.g. script.NodeProperties.attributes) must arrive
|
|
340
|
+
# as an object whose every value matches a declared primitive. Keys are JSON object keys,
|
|
341
|
+
# so they are strings by construction. The Hash passes through unchanged once validated.
|
|
342
|
+
def check_map(field, raw)
|
|
343
|
+
mismatch = map_mismatch(field, raw)
|
|
344
|
+
raise Error::SerializationError, "#{name}##{field.name}#{mismatch}" if mismatch
|
|
345
|
+
|
|
346
|
+
raw
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# The suffix of the error a map value earns, or nil when it conforms — shared by the inbound
|
|
350
|
+
# (SerializationError) and outbound (ArgumentError) checks so the two cannot drift apart. An
|
|
351
|
+
# unrecognized value primitive (none in PRIMITIVE_CHECKS) checks only the shape, matching the
|
|
352
|
+
# lenient default elsewhere.
|
|
353
|
+
def map_mismatch(field, value)
|
|
354
|
+
return " expected a map, got #{value.inspect}" unless value.is_a?(::Hash)
|
|
355
|
+
|
|
356
|
+
value.each do |key, entry|
|
|
357
|
+
mismatch = element_mismatch(field, field.map, entry)
|
|
358
|
+
return "[#{key.inspect}]#{mismatch}" if mismatch
|
|
359
|
+
end
|
|
360
|
+
nil
|
|
286
361
|
end
|
|
287
362
|
|
|
288
363
|
def enum_hash(field)
|
|
@@ -60,11 +60,11 @@ module Selenium
|
|
|
60
60
|
|
|
61
61
|
# Inbound: map a wire token (or list) back to its enum symbol, raising on a token
|
|
62
62
|
# outside our schema so a non-compliant (or newer-than-schema) browser value fails
|
|
63
|
-
# loud instead of silently passing through untyped.
|
|
63
|
+
# loud instead of silently passing through untyped. A null field never reaches here
|
|
64
|
+
# (Record#read handles it), so a nil is a list element and raises too.
|
|
64
65
|
#
|
|
65
66
|
# @api private
|
|
66
67
|
def self.to_symbol(name, value, enum)
|
|
67
|
-
return value if value.nil?
|
|
68
68
|
return value.map { |element| to_symbol(name, element, enum) } if value.is_a?(::Array)
|
|
69
69
|
|
|
70
70
|
enum.key(value) || raise(Error::SerializationError, "#{name} received an unknown value: #{value.inspect}")
|