selenium-webdriver 4.35.0 → 4.47.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 +111 -0
- data/Gemfile +1 -4
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/README.md +43 -23
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +5971 -0
- data/bin/selenium-manager.cdx.json +11629 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/server.rb +30 -5
- data/lib/selenium/webdriver/atoms/findElements.js +272 -54
- data/lib/selenium/webdriver/atoms/getAttribute.js +152 -6
- data/lib/selenium/webdriver/atoms/isDisplayed.js +385 -28
- data/lib/selenium/webdriver/bidi/browser.rb +71 -0
- data/lib/selenium/webdriver/bidi/browsing_context.rb +3 -2
- data/lib/selenium/webdriver/bidi/{log/filter_by.rb → error.rb} +20 -16
- data/lib/selenium/webdriver/bidi/log_handler.rb +5 -0
- data/lib/selenium/webdriver/bidi/network/cookies.rb +13 -9
- data/lib/selenium/webdriver/bidi/network/credentials.rb +4 -0
- data/lib/selenium/webdriver/bidi/network/headers.rb +4 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_auth.rb +4 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_item.rb +4 -0
- data/lib/selenium/webdriver/bidi/network/intercepted_request.rb +20 -4
- data/lib/selenium/webdriver/bidi/network/intercepted_response.rb +24 -6
- data/lib/selenium/webdriver/bidi/network/url_pattern.rb +4 -0
- data/lib/selenium/webdriver/bidi/network.rb +18 -9
- data/lib/selenium/webdriver/bidi/protocol/bluetooth.rb +495 -0
- data/lib/selenium/webdriver/bidi/protocol/browser.rb +250 -0
- data/lib/selenium/webdriver/bidi/protocol/browsing_context.rb +798 -0
- data/lib/selenium/webdriver/bidi/{log/base_log_entry.rb → protocol/domain.rb} +22 -11
- data/lib/selenium/webdriver/bidi/protocol/emulation.rb +448 -0
- data/lib/selenium/webdriver/bidi/protocol/error_code.rb +66 -0
- data/lib/selenium/webdriver/bidi/protocol/input.rb +354 -0
- data/lib/selenium/webdriver/bidi/protocol/log.rb +115 -0
- data/lib/selenium/webdriver/bidi/protocol/network.rb +720 -0
- data/lib/selenium/webdriver/bidi/protocol/permissions.rb +75 -0
- data/lib/selenium/webdriver/bidi/protocol/script.rb +1052 -0
- data/lib/selenium/webdriver/bidi/protocol/session.rb +286 -0
- data/lib/selenium/webdriver/bidi/protocol/speculation.rb +58 -0
- data/lib/selenium/webdriver/bidi/protocol/storage.rb +183 -0
- data/lib/selenium/webdriver/bidi/protocol/user_agent_client_hints.rb +88 -0
- data/lib/selenium/webdriver/bidi/protocol/web_extension.rb +132 -0
- data/lib/selenium/webdriver/bidi/protocol.rb +42 -0
- data/lib/selenium/webdriver/bidi/serialization/record.rb +402 -0
- data/lib/selenium/webdriver/bidi/serialization/union.rb +156 -0
- data/lib/selenium/webdriver/bidi/serialization.rb +90 -0
- data/lib/selenium/webdriver/bidi/session.rb +4 -0
- data/lib/selenium/webdriver/bidi/support/bidi_generate.rb +1420 -0
- data/lib/selenium/webdriver/bidi/support/check_generated.rb +63 -0
- data/lib/selenium/webdriver/bidi/transport.rb +57 -0
- data/lib/selenium/webdriver/bidi.rb +4 -1
- data/lib/selenium/webdriver/chrome/driver.rb +4 -3
- data/lib/selenium/webdriver/chrome/service.rb +13 -0
- data/lib/selenium/webdriver/chromium/driver.rb +0 -1
- data/lib/selenium/webdriver/chromium/options.rb +23 -1
- data/lib/selenium/webdriver/chromium/profile.rb +6 -0
- data/lib/selenium/webdriver/common/child_process.rb +2 -1
- data/lib/selenium/webdriver/common/client_config.rb +97 -0
- data/lib/selenium/webdriver/common/driver.rb +13 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -7
- data/lib/selenium/webdriver/common/driver_extensions/{has_bidi.rb → has_session_events.rb} +19 -7
- data/lib/selenium/webdriver/common/driver_finder.rb +35 -25
- data/lib/selenium/webdriver/common/error.rb +10 -3
- data/lib/selenium/webdriver/common/local_driver.rb +29 -12
- data/lib/selenium/webdriver/common/logger.rb +28 -0
- data/lib/selenium/webdriver/common/manager.rb +2 -0
- data/lib/selenium/webdriver/common/options.rb +41 -2
- data/lib/selenium/webdriver/common/platform.rb +1 -3
- data/lib/selenium/webdriver/common/proxy.rb +1 -9
- data/lib/selenium/webdriver/common/selenium_manager.rb +2 -1
- data/lib/selenium/webdriver/common/service.rb +4 -8
- data/lib/selenium/webdriver/common/service_manager.rb +36 -4
- data/lib/selenium/webdriver/common/socket_poller.rb +1 -1
- data/lib/selenium/webdriver/common/takes_screenshot.rb +1 -1
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +1 -1
- data/lib/selenium/webdriver/common/wait.rb +4 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +73 -37
- data/lib/selenium/webdriver/common.rb +2 -1
- data/lib/selenium/webdriver/devtools/response.rb +3 -3
- data/lib/selenium/webdriver/devtools.rb +1 -1
- data/lib/selenium/webdriver/edge/driver.rb +4 -3
- data/lib/selenium/webdriver/edge/service.rb +14 -0
- data/lib/selenium/webdriver/firefox/driver.rb +4 -6
- data/lib/selenium/webdriver/firefox/options.rb +19 -0
- data/lib/selenium/webdriver/firefox/profile.rb +13 -6
- data/lib/selenium/webdriver/firefox/service.rb +31 -2
- data/lib/selenium/webdriver/ie/driver.rb +4 -3
- data/lib/selenium/webdriver/ie/service.rb +10 -0
- data/lib/selenium/webdriver/remote/bidi_bridge.rb +44 -10
- data/lib/selenium/webdriver/remote/bridge.rb +20 -14
- data/lib/selenium/webdriver/remote/driver.rb +15 -4
- data/lib/selenium/webdriver/remote/features.rb +26 -1
- data/lib/selenium/webdriver/remote/http/common.rb +57 -12
- data/lib/selenium/webdriver/remote/http/curb.rb +6 -8
- data/lib/selenium/webdriver/remote/http/default.rb +56 -39
- data/lib/selenium/webdriver/safari/driver.rb +4 -3
- data/lib/selenium/webdriver/safari/options.rb +23 -4
- data/lib/selenium/webdriver/safari.rb +1 -6
- data/lib/selenium/webdriver/support/block_event_listener.rb +5 -1
- data/lib/selenium/webdriver/support/color.rb +14 -14
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +5 -1
- data/lib/selenium/webdriver/support/guards/guard.rb +30 -14
- data/lib/selenium/webdriver/support/guards.rb +11 -4
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +7 -2
- data/selenium-webdriver.gemspec +1 -1
- metadata +33 -11
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +0 -35
- data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +0 -33
- data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +0 -33
- data/lib/selenium/webdriver/bidi/log_inspector.rb +0 -147
|
@@ -0,0 +1,156 @@
|
|
|
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 BiDi
|
|
23
|
+
module Serialization
|
|
24
|
+
# Resolves a wire payload to the right Data variant: a shared discriminator gives
|
|
25
|
+
# table dispatch; presence rules and a no-tag fallback cover unions without one.
|
|
26
|
+
# Subclassed (never instantiated) — each union holds its own dispatch table.
|
|
27
|
+
#
|
|
28
|
+
# class Locator < Serialization::Union
|
|
29
|
+
# discriminator 'type'
|
|
30
|
+
# variants('css' => 'BrowsingContext::CssLocator')
|
|
31
|
+
# end
|
|
32
|
+
#
|
|
33
|
+
# @api private
|
|
34
|
+
class Union
|
|
35
|
+
class << self
|
|
36
|
+
# values maps each variant's discriminator symbol to its wire token, so an
|
|
37
|
+
# inbound payload tag (a wire string) can be matched to the symbol-keyed table.
|
|
38
|
+
def discriminator(wire_key, values = {})
|
|
39
|
+
@discriminator = wire_key
|
|
40
|
+
@discriminator_values = values
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def variants(table) = @variants = table
|
|
44
|
+
def presence(rules) = @presence = rules
|
|
45
|
+
def fallback(path) = @fallback = path
|
|
46
|
+
|
|
47
|
+
# Declared (via the schema's `objectOnly` signal) on a union whose every arm is an
|
|
48
|
+
# object, so a non-Hash payload is a schema violation rather than a scalar arm.
|
|
49
|
+
def object_only = @object_only = true
|
|
50
|
+
|
|
51
|
+
# Declared (via the schema's `scalarValues` signal) on a non-object_only union whose
|
|
52
|
+
# bare-scalar arms are a fixed set of literals (input.Origin's "viewport" / "pointer").
|
|
53
|
+
# An outbound scalar outside that set matches no arm, so it is a caller error.
|
|
54
|
+
def scalar_values(*values) = @scalar_values = values
|
|
55
|
+
|
|
56
|
+
# A non-Hash payload is a bare scalar arm (e.g. input.Origin's "viewport") with no
|
|
57
|
+
# object to dispatch on, so it is returned unchanged — unless every arm is an object
|
|
58
|
+
# (object_only), where a non-Hash cannot match any variant and is a wire error.
|
|
59
|
+
def from_json(json_payload)
|
|
60
|
+
unless json_payload.is_a?(::Hash)
|
|
61
|
+
return json_payload unless @object_only
|
|
62
|
+
|
|
63
|
+
raise Error::WebDriverError, "#{name} expected an object on the wire, got #{json_payload.inspect}"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
variant = select(json_payload)
|
|
67
|
+
unless variant
|
|
68
|
+
raise Error::WebDriverError,
|
|
69
|
+
"#{name} received a variant not in this Selenium's BiDi schema: #{json_payload.inspect}"
|
|
70
|
+
end
|
|
71
|
+
Protocol.const_get(variant).from_json(json_payload)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Outbound mirror of from_json: build the variant the command's kwargs describe
|
|
75
|
+
# so its typed as_json drives null-vs-absent per field (a flat hash through
|
|
76
|
+
# Transport cannot). Dispatch keys are wire names equal to their ruby kwarg
|
|
77
|
+
# (asserted at generation), so they match the kwargs by symbol. A mismatch here
|
|
78
|
+
# is a caller error (unlike an unknown inbound value), so it fails loudly.
|
|
79
|
+
def build(**kwargs)
|
|
80
|
+
variant = outbound_variant(kwargs) ||
|
|
81
|
+
raise(::ArgumentError, "no #{name} variant matches #{kwargs.inspect}")
|
|
82
|
+
klass = Protocol.const_get(variant)
|
|
83
|
+
# An omitted optional arrives as UNSET; forward only what was provided. A provided
|
|
84
|
+
# key that isn't a field of the chosen variant is an invalid combination for this union.
|
|
85
|
+
provided = kwargs.reject { |_, value| UNSET.equal?(value) }
|
|
86
|
+
invalid = provided.keys - klass.fields.map(&:name)
|
|
87
|
+
return klass.new(**provided) if invalid.empty?
|
|
88
|
+
|
|
89
|
+
raise ::ArgumentError, "invalid combination for #{name}: #{invalid.join(', ')}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Outbound mirror of from_json: is +value+ one this union accepts? Any variant is accepted,
|
|
93
|
+
# and a variant that is itself a union recurses (e.g. LocalValue's RemoteReference fallback).
|
|
94
|
+
# A non-object_only union (e.g. input.Origin) also admits one of its pinned bare-scalar
|
|
95
|
+
# literals; an object (a Hash or another union's record) that matched no variant does not.
|
|
96
|
+
def valid_outbound?(value)
|
|
97
|
+
return true if variant_refs.any? { |ref| variant_accepts?(ref, value) }
|
|
98
|
+
|
|
99
|
+
!@object_only && scalar_arm?(value)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
# A bare-scalar arm must be one of the literals the schema pinned for this union
|
|
105
|
+
# (scalar_values, e.g. input.Origin's "viewport" / "pointer"). The generator guarantees a
|
|
106
|
+
# non-object_only union declares them, so no runtime guard is needed here.
|
|
107
|
+
def scalar_arm?(value)
|
|
108
|
+
@scalar_values.include?(value)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Every variant's class name: the discriminated table, the presence paths, and the fallback.
|
|
112
|
+
def variant_refs
|
|
113
|
+
@variant_refs ||= [*@variants&.values, *@presence&.keys, @fallback].compact
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# A variant that is itself a union recurses; a record variant is matched by instance.
|
|
117
|
+
def variant_accepts?(ref, value)
|
|
118
|
+
klass = (@variant_classes ||= {})[ref] ||= Protocol.const_get(ref)
|
|
119
|
+
klass < Union ? klass.valid_outbound?(value) : value.is_a?(klass)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# The discriminator value may legitimately be null (e.g. script.NullValue's
|
|
123
|
+
# "null" tag), so it is matched by key presence.
|
|
124
|
+
def select(json_payload)
|
|
125
|
+
variant_for(payload_tag(json_payload)) { |k| json_payload.key?(k) }
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# An explicit nil kwarg still counts as supplied; a non-nullable field set to nil is
|
|
129
|
+
# rejected at construction (Data.new), not here.
|
|
130
|
+
def outbound_variant(kwargs)
|
|
131
|
+
tag = @discriminator ? kwargs.fetch(@discriminator.to_sym, UNSET) : UNSET
|
|
132
|
+
variant_for(tag) { |k| kwargs.key?(k.to_sym) && !UNSET.equal?(kwargs[k.to_sym]) }
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# The matching variant's ref, or nil when none matches (the fallback if declared).
|
|
136
|
+
def variant_for(tag, &supplied)
|
|
137
|
+
return @variants[tag] if !UNSET.equal?(tag) && @variants&.key?(tag)
|
|
138
|
+
|
|
139
|
+
@presence&.each { |path, keys| return path if keys.all?(&supplied) }
|
|
140
|
+
@fallback
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# The wire tag mapped back to its variant symbol (the table's key); an
|
|
144
|
+
# unrecognized tag falls through as-is so select misses and from_json raises.
|
|
145
|
+
def payload_tag(json_payload)
|
|
146
|
+
return UNSET unless @discriminator && json_payload.key?(@discriminator)
|
|
147
|
+
|
|
148
|
+
wire = json_payload[@discriminator]
|
|
149
|
+
@discriminator_values.key(wire) || wire
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end # BiDi
|
|
155
|
+
end # WebDriver
|
|
156
|
+
end # Selenium
|
|
@@ -0,0 +1,90 @@
|
|
|
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 BiDi
|
|
23
|
+
# Wire round-trip runtime for the generated protocol layer: the value-type bases
|
|
24
|
+
# (Record, Union), the omit sentinel (UNSET), outbound enum validation, and the
|
|
25
|
+
# strict-inbound toggle.
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
module Serialization
|
|
29
|
+
# Sentinel for an omitted optional: dropped from the payload entirely, vs nil which
|
|
30
|
+
# a nullable field serializes as wire null.
|
|
31
|
+
#
|
|
32
|
+
# @api private
|
|
33
|
+
UNSET = ::Object.new
|
|
34
|
+
def UNSET.inspect = 'UNSET'
|
|
35
|
+
UNSET.freeze
|
|
36
|
+
|
|
37
|
+
# Strict inbound mode. Off by default: a required field missing from a response is
|
|
38
|
+
# tolerated as omitted and warned, so a schema ahead of the browser does not block the
|
|
39
|
+
# caller. When SE_BIDI_STRICT is set to anything but 0/false, that same case escalates
|
|
40
|
+
# to an error for callers who want it.
|
|
41
|
+
#
|
|
42
|
+
# @api private
|
|
43
|
+
def self.strict?
|
|
44
|
+
value = ENV.fetch('SE_BIDI_STRICT', '').strip.downcase
|
|
45
|
+
!value.empty? && value != '0' && value != 'false'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Validates an outbound enum argument: +value+ is a symbol (or list of symbols) that
|
|
49
|
+
# must be a key of the enum hash (+{symbol => wire_token}+), so a bad value fails
|
|
50
|
+
# locally with a clear error instead of a round-trip. Outbound only; inbound wire
|
|
51
|
+
# tokens are mapped and checked separately in +to_symbol+.
|
|
52
|
+
#
|
|
53
|
+
# @api private
|
|
54
|
+
def self.validate!(name, value, enum)
|
|
55
|
+
return if UNSET.equal?(value) || value.nil?
|
|
56
|
+
|
|
57
|
+
elements = value.is_a?(::Array) ? value : [value]
|
|
58
|
+
invalid = elements.reject { |element| enum.key?(element) }
|
|
59
|
+
return if invalid.empty?
|
|
60
|
+
|
|
61
|
+
raise ::ArgumentError, "#{name} must be one of #{enum.keys.inspect}, got #{invalid.inspect}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Outbound: map a validated enum symbol (or list) to the wire token(s) to serialize.
|
|
65
|
+
#
|
|
66
|
+
# @api private
|
|
67
|
+
def self.to_wire(value, enum)
|
|
68
|
+
return value if UNSET.equal?(value) || value.nil?
|
|
69
|
+
|
|
70
|
+
value.is_a?(::Array) ? value.map { |element| enum.fetch(element) } : enum.fetch(value)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Inbound: map a wire token (or list) back to its enum symbol, raising on a token
|
|
74
|
+
# outside our schema so a non-compliant (or newer-than-schema) browser value fails
|
|
75
|
+
# loud instead of silently passing through untyped.
|
|
76
|
+
#
|
|
77
|
+
# @api private
|
|
78
|
+
def self.to_symbol(name, value, enum)
|
|
79
|
+
return value if value.nil?
|
|
80
|
+
return value.map { |element| to_symbol(name, element, enum) } if value.is_a?(::Array)
|
|
81
|
+
|
|
82
|
+
enum.key(value) || raise(Error::WebDriverError, "#{name} received an unknown value: #{value.inspect}")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end # BiDi
|
|
86
|
+
end # WebDriver
|
|
87
|
+
end # Selenium
|
|
88
|
+
|
|
89
|
+
require 'selenium/webdriver/bidi/serialization/record'
|
|
90
|
+
require 'selenium/webdriver/bidi/serialization/union'
|