selenium-webdriver 4.45.0 → 4.48.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +46 -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 +5940 -0
  6. data/bin/selenium-manager.cdx.json +11708 -0
  7. data/bin/windows/selenium-manager.exe +0 -0
  8. data/lib/selenium/webdriver/bidi/error.rb +48 -0
  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/{common/driver_extensions/has_bidi.rb → bidi/protocol/domain.rb} +23 -13
  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 +399 -0
  27. data/lib/selenium/webdriver/bidi/serialization/union.rb +160 -0
  28. data/lib/selenium/webdriver/bidi/serialization.rb +78 -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/websocket_connection.rb +64 -26
  48. data/lib/selenium/webdriver/common.rb +1 -1
  49. data/lib/selenium/webdriver/edge/driver.rb +3 -3
  50. data/lib/selenium/webdriver/edge/service.rb +4 -1
  51. data/lib/selenium/webdriver/firefox/driver.rb +3 -6
  52. data/lib/selenium/webdriver/firefox/options.rb +19 -0
  53. data/lib/selenium/webdriver/firefox/profile.rb +13 -6
  54. data/lib/selenium/webdriver/ie/driver.rb +3 -3
  55. data/lib/selenium/webdriver/remote/bidi_bridge.rb +41 -9
  56. data/lib/selenium/webdriver/remote/bridge.rb +8 -10
  57. data/lib/selenium/webdriver/remote/driver.rb +14 -4
  58. data/lib/selenium/webdriver/remote/http/common.rb +25 -12
  59. data/lib/selenium/webdriver/remote/http/default.rb +56 -39
  60. data/lib/selenium/webdriver/safari/driver.rb +3 -3
  61. data/lib/selenium/webdriver/safari/options.rb +16 -1
  62. data/lib/selenium/webdriver/support/guards/guard.rb +20 -3
  63. data/lib/selenium/webdriver/support/guards.rb +9 -3
  64. data/lib/selenium/webdriver/version.rb +1 -1
  65. metadata +29 -3
@@ -0,0 +1,160 @@
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"), valid only
57
+ # as a literal the schema pins; under object_only it cannot match any variant at all.
58
+ def from_json(json_payload)
59
+ unless json_payload.is_a?(::Hash)
60
+ if @object_only
61
+ raise Error::SerializationError,
62
+ "#{name} expected an object on the wire, got #{json_payload.inspect}"
63
+ end
64
+ return json_payload if scalar_arm?(json_payload)
65
+
66
+ raise Error::SerializationError,
67
+ "#{name} received a scalar not in this Selenium's BiDi schema: #{json_payload.inspect}"
68
+ end
69
+
70
+ variant = select(json_payload)
71
+ unless variant
72
+ raise Error::SerializationError,
73
+ "#{name} received a variant not in this Selenium's BiDi schema: #{json_payload.inspect}"
74
+ end
75
+ Protocol.const_get(variant).from_json(json_payload)
76
+ end
77
+
78
+ # Outbound mirror of from_json: build the variant the command's kwargs describe
79
+ # so its typed as_json drives null-vs-absent per field (a flat hash through
80
+ # Transport cannot). Dispatch keys are wire names equal to their ruby kwarg
81
+ # (asserted at generation), so they match the kwargs by symbol. A mismatch here
82
+ # is a caller error (unlike an unknown inbound value), so it fails loudly.
83
+ def build(**kwargs)
84
+ variant = outbound_variant(kwargs) ||
85
+ raise(::ArgumentError, "no #{name} variant matches #{kwargs.inspect}")
86
+ klass = Protocol.const_get(variant)
87
+ # An omitted optional arrives as UNSET; forward only what was provided. A provided
88
+ # key that isn't a field of the chosen variant is an invalid combination for this union.
89
+ provided = kwargs.reject { |_, value| UNSET.equal?(value) }
90
+ invalid = provided.keys - klass.fields.map(&:name)
91
+ return klass.new(**provided) if invalid.empty?
92
+
93
+ raise ::ArgumentError, "invalid combination for #{name}: #{invalid.join(', ')}"
94
+ end
95
+
96
+ # Outbound mirror of from_json: is +value+ one this union accepts? Any variant is accepted,
97
+ # and a variant that is itself a union recurses (e.g. LocalValue's RemoteReference fallback).
98
+ # A non-object_only union (e.g. input.Origin) also admits one of its pinned bare-scalar
99
+ # literals; an object (a Hash or another union's record) that matched no variant does not.
100
+ def valid_outbound?(value)
101
+ return true if variant_refs.any? { |ref| variant_accepts?(ref, value) }
102
+
103
+ !@object_only && scalar_arm?(value)
104
+ end
105
+
106
+ private
107
+
108
+ # A bare-scalar arm must be one of the literals the schema pinned for this union
109
+ # (scalar_values, e.g. input.Origin's "viewport" / "pointer"). The generator guarantees a
110
+ # non-object_only union declares them, so no runtime guard is needed here.
111
+ def scalar_arm?(value)
112
+ @scalar_values.include?(value)
113
+ end
114
+
115
+ # Every variant's class name: the discriminated table, the presence paths, and the fallback.
116
+ def variant_refs
117
+ @variant_refs ||= [*@variants&.values, *@presence&.keys, @fallback].compact
118
+ end
119
+
120
+ # A variant that is itself a union recurses; a record variant is matched by instance.
121
+ def variant_accepts?(ref, value)
122
+ klass = (@variant_classes ||= {})[ref] ||= Protocol.const_get(ref)
123
+ klass < Union ? klass.valid_outbound?(value) : value.is_a?(klass)
124
+ end
125
+
126
+ # The discriminator value may legitimately be null (e.g. script.NullValue's
127
+ # "null" tag), so it is matched by key presence.
128
+ def select(json_payload)
129
+ variant_for(payload_tag(json_payload)) { |k| json_payload.key?(k) }
130
+ end
131
+
132
+ # An explicit nil kwarg still counts as supplied; a non-nullable field set to nil is
133
+ # rejected at construction (Data.new), not here.
134
+ def outbound_variant(kwargs)
135
+ tag = @discriminator ? kwargs.fetch(@discriminator.to_sym, UNSET) : UNSET
136
+ variant_for(tag) { |k| kwargs.key?(k.to_sym) && !UNSET.equal?(kwargs[k.to_sym]) }
137
+ end
138
+
139
+ # The matching variant's ref, or nil when none matches (the fallback if declared).
140
+ def variant_for(tag, &supplied)
141
+ return @variants[tag] if !UNSET.equal?(tag) && @variants&.key?(tag)
142
+
143
+ @presence&.each { |path, keys| return path if keys.all?(&supplied) }
144
+ @fallback
145
+ end
146
+
147
+ # The wire tag mapped back to its variant symbol (the table's key); an
148
+ # unrecognized tag falls through as-is so select misses and from_json raises.
149
+ def payload_tag(json_payload)
150
+ return UNSET unless @discriminator && json_payload.key?(@discriminator)
151
+
152
+ wire = json_payload[@discriminator]
153
+ @discriminator_values.key(wire) || wire
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end # BiDi
159
+ end # WebDriver
160
+ end # Selenium
@@ -0,0 +1,78 @@
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), and outbound enum validation.
25
+ #
26
+ # @api private
27
+ module Serialization
28
+ # Sentinel for an omitted optional: dropped from the payload entirely, vs nil which
29
+ # a nullable field serializes as wire null.
30
+ #
31
+ # @api private
32
+ UNSET = ::Object.new
33
+ def UNSET.inspect = 'UNSET'
34
+ UNSET.freeze
35
+
36
+ # Validates an outbound enum argument: +value+ is a symbol (or list of symbols) that
37
+ # must be a key of the enum hash (+{symbol => wire_token}+), so a bad value fails
38
+ # locally with a clear error instead of a round-trip. Outbound only; inbound wire
39
+ # tokens are mapped and checked separately in +to_symbol+.
40
+ #
41
+ # @api private
42
+ def self.validate!(name, value, enum)
43
+ return if UNSET.equal?(value) || value.nil?
44
+
45
+ elements = value.is_a?(::Array) ? value : [value]
46
+ invalid = elements.reject { |element| enum.key?(element) }
47
+ return if invalid.empty?
48
+
49
+ raise ::ArgumentError, "#{name} must be one of #{enum.keys.inspect}, got #{invalid.inspect}"
50
+ end
51
+
52
+ # Outbound: map a validated enum symbol (or list) to the wire token(s) to serialize.
53
+ #
54
+ # @api private
55
+ def self.to_wire(value, enum)
56
+ return value if UNSET.equal?(value) || value.nil?
57
+
58
+ value.is_a?(::Array) ? value.map { |element| enum.fetch(element) } : enum.fetch(value)
59
+ end
60
+
61
+ # Inbound: map a wire token (or list) back to its enum symbol, raising on a token
62
+ # outside our schema so a non-compliant (or newer-than-schema) browser value fails
63
+ # loud instead of silently passing through untyped.
64
+ #
65
+ # @api private
66
+ def self.to_symbol(name, value, enum)
67
+ return value if value.nil?
68
+ return value.map { |element| to_symbol(name, element, enum) } if value.is_a?(::Array)
69
+
70
+ enum.key(value) || raise(Error::SerializationError, "#{name} received an unknown value: #{value.inspect}")
71
+ end
72
+ end
73
+ end # BiDi
74
+ end # WebDriver
75
+ end # Selenium
76
+
77
+ require 'selenium/webdriver/bidi/serialization/record'
78
+ require 'selenium/webdriver/bidi/serialization/union'