selenium-webdriver 4.35.0 → 4.41.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 +49 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- 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 +29 -4
- data/lib/selenium/webdriver/atoms/findElements.js +62 -48
- data/lib/selenium/webdriver/atoms/getAttribute.js +17 -6
- data/lib/selenium/webdriver/atoms/isDisplayed.js +34 -23
- 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_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/session.rb +4 -0
- data/lib/selenium/webdriver/bidi.rb +1 -1
- data/lib/selenium/webdriver/chrome/driver.rb +3 -2
- data/lib/selenium/webdriver/chrome/service.rb +10 -0
- data/lib/selenium/webdriver/common/child_process.rb +2 -1
- data/lib/selenium/webdriver/common/driver.rb +0 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_session_events.rb +48 -0
- data/lib/selenium/webdriver/common/error.rb +10 -3
- data/lib/selenium/webdriver/common/local_driver.rb +11 -1
- 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 +20 -1
- data/lib/selenium/webdriver/common/platform.rb +1 -3
- data/lib/selenium/webdriver/common/service.rb +6 -0
- 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/wait.rb +4 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +73 -37
- data/lib/selenium/webdriver/common.rb +1 -0
- data/lib/selenium/webdriver/devtools.rb +1 -1
- data/lib/selenium/webdriver/edge/driver.rb +3 -2
- data/lib/selenium/webdriver/edge/service.rb +11 -0
- data/lib/selenium/webdriver/firefox/driver.rb +3 -2
- data/lib/selenium/webdriver/firefox/service.rb +21 -2
- data/lib/selenium/webdriver/ie/driver.rb +3 -2
- data/lib/selenium/webdriver/ie/service.rb +10 -0
- data/lib/selenium/webdriver/remote/bidi_bridge.rb +4 -2
- data/lib/selenium/webdriver/remote/bridge.rb +12 -4
- data/lib/selenium/webdriver/remote/driver.rb +1 -0
- data/lib/selenium/webdriver/remote/features.rb +26 -1
- data/lib/selenium/webdriver/remote/http/common.rb +32 -0
- data/lib/selenium/webdriver/safari/driver.rb +3 -2
- 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/version.rb +1 -1
- data/lib/selenium/webdriver.rb +7 -2
- metadata +4 -8
- data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +0 -35
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +0 -35
- data/lib/selenium/webdriver/bidi/log/filter_by.rb +0 -40
- 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
|
@@ -29,6 +29,7 @@ module Selenium
|
|
|
29
29
|
include DriverExtensions::UploadsFiles
|
|
30
30
|
include DriverExtensions::HasSessionId
|
|
31
31
|
include DriverExtensions::HasFileDownloads
|
|
32
|
+
include DriverExtensions::HasSessionEvents
|
|
32
33
|
|
|
33
34
|
def initialize(capabilities: nil, options: nil, service: nil, url: nil, **)
|
|
34
35
|
raise ArgumentError, "Can not set :service object on #{self.class}" if service
|
|
@@ -25,7 +25,8 @@ module Selenium
|
|
|
25
25
|
upload_file: [:post, 'session/:session_id/se/file'],
|
|
26
26
|
get_downloadable_files: [:get, 'session/:session_id/se/files'],
|
|
27
27
|
download_file: [:post, 'session/:session_id/se/files'],
|
|
28
|
-
delete_downloadable_files: [:delete, 'session/:session_id/se/files']
|
|
28
|
+
delete_downloadable_files: [:delete, 'session/:session_id/se/files'],
|
|
29
|
+
fire_session_event: [:post, 'session/:session_id/se/event']
|
|
29
30
|
}.freeze
|
|
30
31
|
|
|
31
32
|
def add_commands(commands)
|
|
@@ -69,6 +70,30 @@ module Selenium
|
|
|
69
70
|
def delete_downloadable_files
|
|
70
71
|
execute :delete_downloadable_files
|
|
71
72
|
end
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Fires a custom session event to the remote server event bus.
|
|
76
|
+
# This allows test code to trigger server-side utilities that subscribe to
|
|
77
|
+
# the event bus.
|
|
78
|
+
#
|
|
79
|
+
# @param [String] event_type The type of event (e.g., "test:failed", "log:collect")
|
|
80
|
+
# @param [Hash] payload Optional data to include with the event
|
|
81
|
+
# @return [Hash] Response data including success status, event type, and timestamp
|
|
82
|
+
#
|
|
83
|
+
# @example Fire a simple event
|
|
84
|
+
# driver.fire_session_event("test:started")
|
|
85
|
+
#
|
|
86
|
+
# @example Fire an event with payload
|
|
87
|
+
# driver.fire_session_event("test:failed", {
|
|
88
|
+
# testName: "LoginTest",
|
|
89
|
+
# error: "Element not found"
|
|
90
|
+
# })
|
|
91
|
+
#
|
|
92
|
+
def fire_session_event(event_type, payload = nil)
|
|
93
|
+
params = {eventType: event_type}
|
|
94
|
+
params[:payload] = payload if payload
|
|
95
|
+
execute :fire_session_event, {}, params
|
|
96
|
+
end
|
|
72
97
|
end
|
|
73
98
|
end # Remote
|
|
74
99
|
end # WebDriver
|
|
@@ -28,6 +28,7 @@ module Selenium
|
|
|
28
28
|
'Accept' => CONTENT_TYPE,
|
|
29
29
|
'Content-Type' => "#{CONTENT_TYPE}; charset=UTF-8"
|
|
30
30
|
}.freeze
|
|
31
|
+
BINARY_ENCODINGS = [Encoding::BINARY, Encoding::ASCII_8BIT].freeze
|
|
31
32
|
|
|
32
33
|
class << self
|
|
33
34
|
attr_accessor :extra_headers
|
|
@@ -55,6 +56,7 @@ module Selenium
|
|
|
55
56
|
headers['Cache-Control'] = 'no-cache' if verb == :get
|
|
56
57
|
|
|
57
58
|
if command_hash
|
|
59
|
+
command_hash = ensure_utf8_encoding(command_hash)
|
|
58
60
|
payload = JSON.generate(command_hash)
|
|
59
61
|
headers['Content-Length'] = payload.bytesize.to_s if %i[post put].include?(verb)
|
|
60
62
|
|
|
@@ -91,6 +93,36 @@ module Selenium
|
|
|
91
93
|
raise NotImplementedError, 'subclass responsibility'
|
|
92
94
|
end
|
|
93
95
|
|
|
96
|
+
def ensure_utf8_encoding(obj)
|
|
97
|
+
case obj
|
|
98
|
+
when String
|
|
99
|
+
encode_string_to_utf8(obj)
|
|
100
|
+
when Array
|
|
101
|
+
obj.map { |item| ensure_utf8_encoding(item) }
|
|
102
|
+
when Hash
|
|
103
|
+
obj.each_with_object({}) do |(key, value), result|
|
|
104
|
+
result[ensure_utf8_encoding(key)] = ensure_utf8_encoding(value)
|
|
105
|
+
end
|
|
106
|
+
else
|
|
107
|
+
obj
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def encode_string_to_utf8(str)
|
|
112
|
+
return str if str.encoding == Encoding::UTF_8 && str.valid_encoding?
|
|
113
|
+
|
|
114
|
+
if BINARY_ENCODINGS.include?(str.encoding)
|
|
115
|
+
result = str.dup.force_encoding(Encoding::UTF_8)
|
|
116
|
+
return result if result.valid_encoding?
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
str.encode(Encoding::UTF_8)
|
|
120
|
+
rescue EncodingError => e
|
|
121
|
+
raise Error::WebDriverError,
|
|
122
|
+
"Unable to encode string to UTF-8: #{e.message}. " \
|
|
123
|
+
"String encoding: #{str.encoding}, content: #{str.inspect}"
|
|
124
|
+
end
|
|
125
|
+
|
|
94
126
|
def create_response(code, body, content_type)
|
|
95
127
|
code = code.to_i
|
|
96
128
|
body = body.to_s.strip
|
|
@@ -32,8 +32,9 @@ module Selenium
|
|
|
32
32
|
include LocalDriver
|
|
33
33
|
|
|
34
34
|
def initialize(options: nil, service: nil, url: nil, **)
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
initialize_local_driver(options, service, url) do |caps, driver_url|
|
|
36
|
+
super(caps: caps, url: driver_url, **)
|
|
37
|
+
end
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def browser
|
|
@@ -25,9 +25,13 @@ module Selenium
|
|
|
25
25
|
@callback = callback
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def method_missing(meth, *)
|
|
28
|
+
def method_missing(meth, *)
|
|
29
29
|
@callback.call(meth, *)
|
|
30
30
|
end
|
|
31
|
+
|
|
32
|
+
def respond_to_missing?(_meth, _include_private = false)
|
|
33
|
+
true
|
|
34
|
+
end
|
|
31
35
|
end # BlockEventListener
|
|
32
36
|
end # Support
|
|
33
37
|
end # WebDriver
|
|
@@ -72,26 +72,26 @@ module Selenium
|
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def self.from_hsl(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if
|
|
82
|
-
r =
|
|
75
|
+
def self.from_hsl(hue, sat, light, alpha)
|
|
76
|
+
hue = Float(hue) / 360
|
|
77
|
+
sat = Float(sat) / 100
|
|
78
|
+
light = Float(light) / 100
|
|
79
|
+
alpha = Float(alpha || 1)
|
|
80
|
+
|
|
81
|
+
if sat.zero?
|
|
82
|
+
r = light
|
|
83
83
|
g = r
|
|
84
84
|
b = r
|
|
85
85
|
else
|
|
86
|
-
luminocity2 =
|
|
87
|
-
luminocity1 = (
|
|
86
|
+
luminocity2 = light < 0.5 ? light * (sat + 1) : light + sat - (light * sat)
|
|
87
|
+
luminocity1 = (light * 2) - luminocity2
|
|
88
88
|
|
|
89
|
-
r = hue_to_rgb(luminocity1, luminocity2,
|
|
90
|
-
g = hue_to_rgb(luminocity1, luminocity2,
|
|
91
|
-
b = hue_to_rgb(luminocity1, luminocity2,
|
|
89
|
+
r = hue_to_rgb(luminocity1, luminocity2, hue + (1.0 / 3.0))
|
|
90
|
+
g = hue_to_rgb(luminocity1, luminocity2, hue)
|
|
91
|
+
b = hue_to_rgb(luminocity1, luminocity2, hue - (1.0 / 3.0))
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
new (r * 255).round, (g * 255).round, (b * 255).round,
|
|
94
|
+
new (r * 255).round, (g * 255).round, (b * 255).round, alpha
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
def self.hue_to_rgb(lum1, lum2, hue)
|
|
@@ -120,9 +120,13 @@ module Selenium
|
|
|
120
120
|
returned
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
def method_missing(meth, ...)
|
|
123
|
+
def method_missing(meth, ...)
|
|
124
124
|
@delegate.__send__(meth, ...)
|
|
125
125
|
end
|
|
126
|
+
|
|
127
|
+
def respond_to_missing?(meth, include_private = false)
|
|
128
|
+
@delegate.respond_to?(meth, include_private) || super
|
|
129
|
+
end
|
|
126
130
|
end # EventFiringBridge
|
|
127
131
|
end # Support
|
|
128
132
|
end # WebDriver
|
data/lib/selenium/webdriver.rb
CHANGED
|
@@ -95,8 +95,13 @@ module Selenium
|
|
|
95
95
|
#
|
|
96
96
|
|
|
97
97
|
def self.logger(**)
|
|
98
|
-
level = $DEBUG || ENV.key?('DEBUG') ? :debug : :info
|
|
99
|
-
@logger ||= WebDriver::Logger.new('Selenium', default_level: level, **)
|
|
98
|
+
level = $DEBUG || ENV.key?('DEBUG') || ENV.key?('SE_DEBUG') ? :debug : :info
|
|
99
|
+
@logger ||= WebDriver::Logger.new('Selenium', default_level: level, **).tap do |logger|
|
|
100
|
+
if ENV.key?('SE_DEBUG')
|
|
101
|
+
logger.debug!
|
|
102
|
+
logger.stderr!
|
|
103
|
+
end
|
|
104
|
+
end
|
|
100
105
|
end
|
|
101
106
|
end # WebDriver
|
|
102
107
|
end # Selenium
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: selenium-webdriver
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.41.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Rodionov
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-02-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: base64
|
|
@@ -283,14 +283,9 @@ files:
|
|
|
283
283
|
- lib/selenium/webdriver/atoms/isDisplayed.js
|
|
284
284
|
- lib/selenium/webdriver/atoms/mutationListener.js
|
|
285
285
|
- lib/selenium/webdriver/bidi.rb
|
|
286
|
+
- lib/selenium/webdriver/bidi/browser.rb
|
|
286
287
|
- lib/selenium/webdriver/bidi/browsing_context.rb
|
|
287
|
-
- lib/selenium/webdriver/bidi/log/base_log_entry.rb
|
|
288
|
-
- lib/selenium/webdriver/bidi/log/console_log_entry.rb
|
|
289
|
-
- lib/selenium/webdriver/bidi/log/filter_by.rb
|
|
290
|
-
- lib/selenium/webdriver/bidi/log/generic_log_entry.rb
|
|
291
|
-
- lib/selenium/webdriver/bidi/log/javascript_log_entry.rb
|
|
292
288
|
- lib/selenium/webdriver/bidi/log_handler.rb
|
|
293
|
-
- lib/selenium/webdriver/bidi/log_inspector.rb
|
|
294
289
|
- lib/selenium/webdriver/bidi/network.rb
|
|
295
290
|
- lib/selenium/webdriver/bidi/network/cookies.rb
|
|
296
291
|
- lib/selenium/webdriver/bidi/network/credentials.rb
|
|
@@ -338,6 +333,7 @@ files:
|
|
|
338
333
|
- lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb
|
|
339
334
|
- lib/selenium/webdriver/common/driver_extensions/has_permissions.rb
|
|
340
335
|
- lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb
|
|
336
|
+
- lib/selenium/webdriver/common/driver_extensions/has_session_events.rb
|
|
341
337
|
- lib/selenium/webdriver/common/driver_extensions/has_session_id.rb
|
|
342
338
|
- lib/selenium/webdriver/common/driver_extensions/prints_page.rb
|
|
343
339
|
- lib/selenium/webdriver/common/driver_extensions/uploads_files.rb
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
class BaseLogEntry
|
|
24
|
-
attr_accessor :level, :text, :timestamp, :stack_trace
|
|
25
|
-
|
|
26
|
-
def initialize(level:, text:, timestamp:, stack_trace:)
|
|
27
|
-
@level = level
|
|
28
|
-
@text = text
|
|
29
|
-
@timestamp = timestamp
|
|
30
|
-
@stack_trace = stack_trace
|
|
31
|
-
end
|
|
32
|
-
end # BaseLogEntry
|
|
33
|
-
end # BiDi
|
|
34
|
-
end # WebDriver
|
|
35
|
-
end # Selenium
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
class ConsoleLogEntry < GenericLogEntry
|
|
24
|
-
attr_accessor :method, :realm, :args
|
|
25
|
-
|
|
26
|
-
def initialize(method:, realm:, args:, **)
|
|
27
|
-
super(**)
|
|
28
|
-
@method = method
|
|
29
|
-
@realm = realm
|
|
30
|
-
@args = args
|
|
31
|
-
end
|
|
32
|
-
end # ConsoleLogEntry
|
|
33
|
-
end # BiDi
|
|
34
|
-
end # WebDriver
|
|
35
|
-
end # Selenium
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
class FilterBy
|
|
24
|
-
attr_accessor :level
|
|
25
|
-
|
|
26
|
-
def initialize(level)
|
|
27
|
-
@level = level
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.log_level(level = nil)
|
|
31
|
-
unless %w[debug error info warning].include?(level)
|
|
32
|
-
raise Error::WebDriverError,
|
|
33
|
-
"Valid log levels are 'debug', 'error', 'info' and 'warning'. Received: #{level}"
|
|
34
|
-
end
|
|
35
|
-
FilterBy.new(level)
|
|
36
|
-
end
|
|
37
|
-
end # FilterBy
|
|
38
|
-
end # BiDi
|
|
39
|
-
end # WebDriver
|
|
40
|
-
end # Selenium
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
class GenericLogEntry < BaseLogEntry
|
|
24
|
-
attr_accessor :type
|
|
25
|
-
|
|
26
|
-
def initialize(level:, text:, timestamp:, type:, stack_trace:)
|
|
27
|
-
super(level: level, text: text, timestamp: timestamp, stack_trace: stack_trace)
|
|
28
|
-
@type = type
|
|
29
|
-
end
|
|
30
|
-
end # GenericLogEntry
|
|
31
|
-
end # BiDi
|
|
32
|
-
end # WebDriver
|
|
33
|
-
end # Selenium
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
class JavascriptLogEntry < GenericLogEntry
|
|
24
|
-
attr_accessor :type
|
|
25
|
-
|
|
26
|
-
def initialize(level:, text:, timestamp:, type:, stack_trace:)
|
|
27
|
-
super
|
|
28
|
-
@type = 'javascript'
|
|
29
|
-
end
|
|
30
|
-
end # JavascriptLogEntry
|
|
31
|
-
end # BiDi
|
|
32
|
-
end # WebDriver
|
|
33
|
-
end # Selenium
|
|
@@ -1,147 +0,0 @@
|
|
|
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
|
-
# This file is automatically generated. Any changes will be lost!
|
|
21
|
-
|
|
22
|
-
require_relative 'log/base_log_entry'
|
|
23
|
-
require_relative 'log/generic_log_entry'
|
|
24
|
-
require_relative 'log/console_log_entry'
|
|
25
|
-
require_relative 'log/javascript_log_entry'
|
|
26
|
-
require_relative 'log/filter_by'
|
|
27
|
-
|
|
28
|
-
module Selenium
|
|
29
|
-
module WebDriver
|
|
30
|
-
class BiDi
|
|
31
|
-
class LogInspector
|
|
32
|
-
EVENTS = {
|
|
33
|
-
entry_added: 'entryAdded'
|
|
34
|
-
}.freeze
|
|
35
|
-
|
|
36
|
-
LOG_LEVEL = {
|
|
37
|
-
DEBUG: 'debug',
|
|
38
|
-
ERROR: 'error',
|
|
39
|
-
INFO: 'info',
|
|
40
|
-
WARNING: 'warning'
|
|
41
|
-
}.freeze
|
|
42
|
-
|
|
43
|
-
def initialize(driver, browsing_context_ids = nil)
|
|
44
|
-
WebDriver.logger.deprecate('LogInspector class',
|
|
45
|
-
'Script class with driver.script',
|
|
46
|
-
id: :log_inspector)
|
|
47
|
-
|
|
48
|
-
unless driver.capabilities.web_socket_url
|
|
49
|
-
raise Error::WebDriverError,
|
|
50
|
-
'WebDriver instance must support BiDi protocol'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
@bidi = driver.bidi
|
|
54
|
-
@bidi.session.subscribe('log.entryAdded', browsing_context_ids)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def on_console_entry(filter_by = nil, &block)
|
|
58
|
-
check_valid_filter(filter_by)
|
|
59
|
-
|
|
60
|
-
on_log do |params|
|
|
61
|
-
type = params['type']
|
|
62
|
-
console_log_events(params, filter_by, &block) if type.eql?('console')
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def on_javascript_log(filter_by = nil, &block)
|
|
67
|
-
check_valid_filter(filter_by)
|
|
68
|
-
|
|
69
|
-
on_log do |params|
|
|
70
|
-
type = params['type']
|
|
71
|
-
javascript_log_events(params, filter_by, &block) if type.eql?('javascript')
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def on_javascript_exception(&block)
|
|
76
|
-
on_log do |params|
|
|
77
|
-
type = params['type']
|
|
78
|
-
javascript_log_events(params, FilterBy.log_level('error'), &block) if type.eql?('javascript')
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def on_log(filter_by = nil, &block)
|
|
83
|
-
unless filter_by.nil?
|
|
84
|
-
check_valid_filter(filter_by)
|
|
85
|
-
|
|
86
|
-
on(:entry_added) do |params|
|
|
87
|
-
yield(params) if params['level'] == filter_by.level
|
|
88
|
-
end
|
|
89
|
-
return
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
on(:entry_added, &block)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
private
|
|
96
|
-
|
|
97
|
-
def on(event, &block)
|
|
98
|
-
event = EVENTS[event] if event.is_a?(Symbol)
|
|
99
|
-
@bidi.add_callback("log.#{event}", &block)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def check_valid_filter(filter_by)
|
|
103
|
-
return if filter_by.nil? || filter_by.instance_of?(FilterBy)
|
|
104
|
-
|
|
105
|
-
raise "Pass valid FilterBy object. Received: #{filter_by.inspect}"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def console_log_events(params, filter_by)
|
|
109
|
-
event = ConsoleLogEntry.new(
|
|
110
|
-
level: params['level'],
|
|
111
|
-
text: params['text'],
|
|
112
|
-
timestamp: params['timestamp'],
|
|
113
|
-
type: params['type'],
|
|
114
|
-
method: params['method'],
|
|
115
|
-
realm: params['realm'],
|
|
116
|
-
args: params['args'],
|
|
117
|
-
stack_trace: params['stackTrace']
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
unless filter_by.nil?
|
|
121
|
-
yield(event) if params['level'] == filter_by.level
|
|
122
|
-
return
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
yield(event)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def javascript_log_events(params, filter_by)
|
|
129
|
-
event = JavascriptLogEntry.new(
|
|
130
|
-
level: params['level'],
|
|
131
|
-
text: params['text'],
|
|
132
|
-
timestamp: params['timestamp'],
|
|
133
|
-
type: params['type'],
|
|
134
|
-
stack_trace: params['stackTrace']
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
unless filter_by.nil?
|
|
138
|
-
yield(event) if params['level'] == filter_by.level
|
|
139
|
-
return
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
yield(event)
|
|
143
|
-
end
|
|
144
|
-
end # LogInspector
|
|
145
|
-
end # Bidi
|
|
146
|
-
end # WebDriver
|
|
147
|
-
end # Selenium
|