selenium-webdriver 4.45.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +36 -0
  3. data/bin/linux/selenium-manager +0 -0
  4. data/bin/macos/selenium-manager +0 -0
  5. data/bin/selenium-manager-THIRD-PARTY-NOTICES.txt +5971 -0
  6. data/bin/selenium-manager.cdx.json +11629 -0
  7. data/bin/windows/selenium-manager.exe +0 -0
  8. data/lib/selenium/webdriver/{common/driver_extensions/has_bidi.rb → bidi/error.rb} +21 -13
  9. data/lib/selenium/webdriver/bidi/protocol/bluetooth.rb +495 -0
  10. data/lib/selenium/webdriver/bidi/protocol/browser.rb +250 -0
  11. data/lib/selenium/webdriver/bidi/protocol/browsing_context.rb +798 -0
  12. data/lib/selenium/webdriver/bidi/protocol/domain.rb +46 -0
  13. data/lib/selenium/webdriver/bidi/protocol/emulation.rb +448 -0
  14. data/lib/selenium/webdriver/bidi/protocol/error_code.rb +66 -0
  15. data/lib/selenium/webdriver/bidi/protocol/input.rb +354 -0
  16. data/lib/selenium/webdriver/bidi/protocol/log.rb +115 -0
  17. data/lib/selenium/webdriver/bidi/protocol/network.rb +720 -0
  18. data/lib/selenium/webdriver/bidi/protocol/permissions.rb +75 -0
  19. data/lib/selenium/webdriver/bidi/protocol/script.rb +1052 -0
  20. data/lib/selenium/webdriver/bidi/protocol/session.rb +286 -0
  21. data/lib/selenium/webdriver/bidi/protocol/speculation.rb +58 -0
  22. data/lib/selenium/webdriver/bidi/protocol/storage.rb +183 -0
  23. data/lib/selenium/webdriver/bidi/protocol/user_agent_client_hints.rb +88 -0
  24. data/lib/selenium/webdriver/bidi/protocol/web_extension.rb +132 -0
  25. data/lib/selenium/webdriver/bidi/protocol.rb +42 -0
  26. data/lib/selenium/webdriver/bidi/serialization/record.rb +402 -0
  27. data/lib/selenium/webdriver/bidi/serialization/union.rb +156 -0
  28. data/lib/selenium/webdriver/bidi/serialization.rb +90 -0
  29. data/lib/selenium/webdriver/bidi/support/bidi_generate.rb +1420 -0
  30. data/lib/selenium/webdriver/bidi/support/check_generated.rb +63 -0
  31. data/lib/selenium/webdriver/bidi/transport.rb +57 -0
  32. data/lib/selenium/webdriver/bidi.rb +3 -0
  33. data/lib/selenium/webdriver/chrome/driver.rb +3 -3
  34. data/lib/selenium/webdriver/chrome/service.rb +4 -1
  35. data/lib/selenium/webdriver/chromium/driver.rb +0 -1
  36. data/lib/selenium/webdriver/chromium/options.rb +20 -0
  37. data/lib/selenium/webdriver/common/client_config.rb +97 -0
  38. data/lib/selenium/webdriver/common/driver.rb +13 -2
  39. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -7
  40. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -7
  41. data/lib/selenium/webdriver/common/driver_finder.rb +4 -3
  42. data/lib/selenium/webdriver/common/local_driver.rb +15 -4
  43. data/lib/selenium/webdriver/common/options.rb +21 -1
  44. data/lib/selenium/webdriver/common/proxy.rb +1 -9
  45. data/lib/selenium/webdriver/common/selenium_manager.rb +2 -1
  46. data/lib/selenium/webdriver/common/takes_screenshot.rb +1 -1
  47. data/lib/selenium/webdriver/common.rb +1 -1
  48. data/lib/selenium/webdriver/edge/driver.rb +3 -3
  49. data/lib/selenium/webdriver/edge/service.rb +4 -1
  50. data/lib/selenium/webdriver/firefox/driver.rb +3 -6
  51. data/lib/selenium/webdriver/firefox/options.rb +19 -0
  52. data/lib/selenium/webdriver/firefox/profile.rb +13 -6
  53. data/lib/selenium/webdriver/ie/driver.rb +3 -3
  54. data/lib/selenium/webdriver/remote/bidi_bridge.rb +41 -9
  55. data/lib/selenium/webdriver/remote/bridge.rb +8 -10
  56. data/lib/selenium/webdriver/remote/driver.rb +14 -4
  57. data/lib/selenium/webdriver/remote/http/common.rb +25 -12
  58. data/lib/selenium/webdriver/remote/http/default.rb +56 -39
  59. data/lib/selenium/webdriver/safari/driver.rb +3 -3
  60. data/lib/selenium/webdriver/safari/options.rb +16 -1
  61. data/lib/selenium/webdriver/support/guards/guard.rb +20 -3
  62. data/lib/selenium/webdriver/support/guards.rb +9 -3
  63. data/lib/selenium/webdriver/version.rb +1 -1
  64. metadata +29 -3
@@ -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'