From 19fadd21b3ea6d4c7cc9269e5d4c680c6800122b Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 20 Oct 2025 18:01:25 -0500 Subject: [PATCH 1/3] [rb] remove deprecated classes for previous implementation of log handling --- rb/Steepfile | 2 - rb/lib/selenium/webdriver/bidi.rb | 1 - .../webdriver/bidi/log/base_log_entry.rb | 35 ----- .../webdriver/bidi/log/console_log_entry.rb | 35 ----- .../selenium/webdriver/bidi/log/filter_by.rb | 40 ----- .../webdriver/bidi/log/generic_log_entry.rb | 33 ---- .../bidi/log/javascript_log_entry.rb | 33 ---- .../selenium/webdriver/bidi/log_inspector.rb | 147 ------------------ .../webdriver/bidi/log/base_log_entry.rbs | 25 --- .../webdriver/bidi/log/console_log_entry.rbs | 21 --- .../selenium/webdriver/bidi/log/filter_by.rbs | 15 -- .../webdriver/bidi/log/generic_log_entry.rbs | 13 -- .../bidi/log/javascript_log_entry.rbs | 13 -- .../selenium/webdriver/bidi/log_inspector.rbs | 33 ---- 14 files changed, 446 deletions(-) delete mode 100644 rb/lib/selenium/webdriver/bidi/log/base_log_entry.rb delete mode 100644 rb/lib/selenium/webdriver/bidi/log/console_log_entry.rb delete mode 100644 rb/lib/selenium/webdriver/bidi/log/filter_by.rb delete mode 100644 rb/lib/selenium/webdriver/bidi/log/generic_log_entry.rb delete mode 100644 rb/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb delete mode 100644 rb/lib/selenium/webdriver/bidi/log_inspector.rb delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log/base_log_entry.rbs delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log/console_log_entry.rbs delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log/filter_by.rbs delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log/generic_log_entry.rbs delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log/javascript_log_entry.rbs delete mode 100644 rb/sig/lib/selenium/webdriver/bidi/log_inspector.rbs diff --git a/rb/Steepfile b/rb/Steepfile index d663fa219ec72..f12a1053cc887 100644 --- a/rb/Steepfile +++ b/rb/Steepfile @@ -57,8 +57,6 @@ target :lib do 'lib/selenium/webdriver/common/interactions/wheel_input.rb', # Cannot override last error on line 71 'lib/selenium/webdriver/common/wait.rb', - # Cannot override params on line 83 - 'lib/selenium/webdriver/bidi/log_inspector.rb', # Kwargs issue on line 74 'lib/selenium/webdriver/common/driver.rb', # issue with the Zipper RBS library on line 54 diff --git a/rb/lib/selenium/webdriver/bidi.rb b/rb/lib/selenium/webdriver/bidi.rb index 25c7393a88f2f..80fc5b92fbe22 100644 --- a/rb/lib/selenium/webdriver/bidi.rb +++ b/rb/lib/selenium/webdriver/bidi.rb @@ -21,7 +21,6 @@ module Selenium module WebDriver class BiDi autoload :Session, 'selenium/webdriver/bidi/session' - autoload :LogInspector, 'selenium/webdriver/bidi/log_inspector' autoload :LogHandler, 'selenium/webdriver/bidi/log_handler' autoload :Browser, 'selenium/webdriver/bidi/browser' autoload :BrowsingContext, 'selenium/webdriver/bidi/browsing_context' diff --git a/rb/lib/selenium/webdriver/bidi/log/base_log_entry.rb b/rb/lib/selenium/webdriver/bidi/log/base_log_entry.rb deleted file mode 100644 index 3706572bf2057..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log/base_log_entry.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module Selenium - module WebDriver - class BiDi - class BaseLogEntry - attr_accessor :level, :text, :timestamp, :stack_trace - - def initialize(level:, text:, timestamp:, stack_trace:) - @level = level - @text = text - @timestamp = timestamp - @stack_trace = stack_trace - end - end # BaseLogEntry - end # BiDi - end # WebDriver -end # Selenium diff --git a/rb/lib/selenium/webdriver/bidi/log/console_log_entry.rb b/rb/lib/selenium/webdriver/bidi/log/console_log_entry.rb deleted file mode 100644 index a8b1c7fe2375f..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log/console_log_entry.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module Selenium - module WebDriver - class BiDi - class ConsoleLogEntry < GenericLogEntry - attr_accessor :method, :realm, :args - - def initialize(method:, realm:, args:, **) - super(**) - @method = method - @realm = realm - @args = args - end - end # ConsoleLogEntry - end # BiDi - end # WebDriver -end # Selenium diff --git a/rb/lib/selenium/webdriver/bidi/log/filter_by.rb b/rb/lib/selenium/webdriver/bidi/log/filter_by.rb deleted file mode 100644 index 81dc49224c423..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log/filter_by.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module Selenium - module WebDriver - class BiDi - class FilterBy - attr_accessor :level - - def initialize(level) - @level = level - end - - def self.log_level(level = nil) - unless %w[debug error info warning].include?(level) - raise Error::WebDriverError, - "Valid log levels are 'debug', 'error', 'info' and 'warning'. Received: #{level}" - end - FilterBy.new(level) - end - end # FilterBy - end # BiDi - end # WebDriver -end # Selenium diff --git a/rb/lib/selenium/webdriver/bidi/log/generic_log_entry.rb b/rb/lib/selenium/webdriver/bidi/log/generic_log_entry.rb deleted file mode 100644 index 6d9986fdf3e17..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module Selenium - module WebDriver - class BiDi - class GenericLogEntry < BaseLogEntry - attr_accessor :type - - def initialize(level:, text:, timestamp:, type:, stack_trace:) - super(level: level, text: text, timestamp: timestamp, stack_trace: stack_trace) - @type = type - end - end # GenericLogEntry - end # BiDi - end # WebDriver -end # Selenium diff --git a/rb/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb b/rb/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb deleted file mode 100644 index f691d54f83947..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -module Selenium - module WebDriver - class BiDi - class JavascriptLogEntry < GenericLogEntry - attr_accessor :type - - def initialize(level:, text:, timestamp:, type:, stack_trace:) - super - @type = 'javascript' - end - end # JavascriptLogEntry - end # BiDi - end # WebDriver -end # Selenium diff --git a/rb/lib/selenium/webdriver/bidi/log_inspector.rb b/rb/lib/selenium/webdriver/bidi/log_inspector.rb deleted file mode 100644 index 133666cec0f01..0000000000000 --- a/rb/lib/selenium/webdriver/bidi/log_inspector.rb +++ /dev/null @@ -1,147 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -# This file is automatically generated. Any changes will be lost! - -require_relative 'log/base_log_entry' -require_relative 'log/generic_log_entry' -require_relative 'log/console_log_entry' -require_relative 'log/javascript_log_entry' -require_relative 'log/filter_by' - -module Selenium - module WebDriver - class BiDi - class LogInspector - EVENTS = { - entry_added: 'entryAdded' - }.freeze - - LOG_LEVEL = { - DEBUG: 'debug', - ERROR: 'error', - INFO: 'info', - WARNING: 'warning' - }.freeze - - def initialize(driver, browsing_context_ids = nil) - WebDriver.logger.deprecate('LogInspector class', - 'Script class with driver.script', - id: :log_inspector) - - unless driver.capabilities.web_socket_url - raise Error::WebDriverError, - 'WebDriver instance must support BiDi protocol' - end - - @bidi = driver.bidi - @bidi.session.subscribe('log.entryAdded', browsing_context_ids) - end - - def on_console_entry(filter_by = nil, &block) - check_valid_filter(filter_by) - - on_log do |params| - type = params['type'] - console_log_events(params, filter_by, &block) if type.eql?('console') - end - end - - def on_javascript_log(filter_by = nil, &block) - check_valid_filter(filter_by) - - on_log do |params| - type = params['type'] - javascript_log_events(params, filter_by, &block) if type.eql?('javascript') - end - end - - def on_javascript_exception(&block) - on_log do |params| - type = params['type'] - javascript_log_events(params, FilterBy.log_level('error'), &block) if type.eql?('javascript') - end - end - - def on_log(filter_by = nil, &block) - unless filter_by.nil? - check_valid_filter(filter_by) - - on(:entry_added) do |params| - yield(params) if params['level'] == filter_by.level - end - return - end - - on(:entry_added, &block) - end - - private - - def on(event, &block) - event = EVENTS[event] if event.is_a?(Symbol) - @bidi.add_callback("log.#{event}", &block) - end - - def check_valid_filter(filter_by) - return if filter_by.nil? || filter_by.instance_of?(FilterBy) - - raise "Pass valid FilterBy object. Received: #{filter_by.inspect}" - end - - def console_log_events(params, filter_by) - event = ConsoleLogEntry.new( - level: params['level'], - text: params['text'], - timestamp: params['timestamp'], - type: params['type'], - method: params['method'], - realm: params['realm'], - args: params['args'], - stack_trace: params['stackTrace'] - ) - - unless filter_by.nil? - yield(event) if params['level'] == filter_by.level - return - end - - yield(event) - end - - def javascript_log_events(params, filter_by) - event = JavascriptLogEntry.new( - level: params['level'], - text: params['text'], - timestamp: params['timestamp'], - type: params['type'], - stack_trace: params['stackTrace'] - ) - - unless filter_by.nil? - yield(event) if params['level'] == filter_by.level - return - end - - yield(event) - end - end # LogInspector - end # Bidi - end # WebDriver -end # Selenium diff --git a/rb/sig/lib/selenium/webdriver/bidi/log/base_log_entry.rbs b/rb/sig/lib/selenium/webdriver/bidi/log/base_log_entry.rbs deleted file mode 100644 index b68966f0d8102..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log/base_log_entry.rbs +++ /dev/null @@ -1,25 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class BaseLogEntry - @level: untyped - - @text: untyped - - @timestamp: untyped - - @stack_trace: untyped - - attr_accessor level: untyped - - attr_accessor text: untyped - - attr_accessor timestamp: untyped - - attr_accessor stack_trace: untyped - - def initialize: (level: untyped, text: untyped, timestamp: untyped, stack_trace: untyped) -> void - end - end - end -end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log/console_log_entry.rbs b/rb/sig/lib/selenium/webdriver/bidi/log/console_log_entry.rbs deleted file mode 100644 index b0b1ca11d80b4..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log/console_log_entry.rbs +++ /dev/null @@ -1,21 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class ConsoleLogEntry < GenericLogEntry - @method: untyped - - @realm: untyped - - @args: untyped - - attr_accessor method: untyped - - attr_accessor realm: untyped - - attr_accessor args: untyped - - def initialize: (method: untyped, realm: untyped, args: untyped, **untyped opts) -> void - end - end - end -end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log/filter_by.rbs b/rb/sig/lib/selenium/webdriver/bidi/log/filter_by.rbs deleted file mode 100644 index 3937dd37c60f2..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log/filter_by.rbs +++ /dev/null @@ -1,15 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class FilterBy - @level: untyped - - attr_accessor level: untyped - - def initialize: (untyped level) -> void - - def self.log_level: (?untyped? level) -> untyped - end - end - end -end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log/generic_log_entry.rbs b/rb/sig/lib/selenium/webdriver/bidi/log/generic_log_entry.rbs deleted file mode 100644 index 71c98b0215e6b..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log/generic_log_entry.rbs +++ /dev/null @@ -1,13 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class GenericLogEntry < BaseLogEntry - @type: untyped - - attr_accessor type: untyped - - def initialize: (level: untyped, text: untyped, timestamp: untyped, type: untyped, stack_trace: untyped) -> void - end - end - end -end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log/javascript_log_entry.rbs b/rb/sig/lib/selenium/webdriver/bidi/log/javascript_log_entry.rbs deleted file mode 100644 index fdb88b70b5a56..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log/javascript_log_entry.rbs +++ /dev/null @@ -1,13 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class JavascriptLogEntry < GenericLogEntry - @type: untyped - - attr_accessor type: untyped - - def initialize: (level: untyped, text: untyped, timestamp: untyped, type: untyped, stack_trace: untyped) -> void - end - end - end -end diff --git a/rb/sig/lib/selenium/webdriver/bidi/log_inspector.rbs b/rb/sig/lib/selenium/webdriver/bidi/log_inspector.rbs deleted file mode 100644 index 565ec3aa46142..0000000000000 --- a/rb/sig/lib/selenium/webdriver/bidi/log_inspector.rbs +++ /dev/null @@ -1,33 +0,0 @@ -module Selenium - module WebDriver - class BiDi - class LogInspector - @bidi: untyped - - EVENTS: Hash[Symbol, String] - - LOG_LEVEL: Hash[Symbol, String] - - def initialize: (untyped driver, ?untyped? browsing_context_ids) -> void - - def on_console_entry: (?untyped? filter_by) { () -> untyped } -> untyped - - def on_javascript_log: (?untyped? filter_by) { () -> untyped } -> untyped - - def on_javascript_exception: () { () -> untyped } -> untyped - - def on_log: (?untyped? filter_by) { (untyped) -> untyped } -> untyped? - - private - - def on: (untyped event) { () -> untyped } -> untyped - - def check_valid_filter: (untyped filter_by) -> (nil | untyped) - - def console_log_events: (untyped params, untyped filter_by) { (untyped) -> untyped } -> untyped? - - def javascript_log_events: (untyped params, untyped filter_by) { (untyped) -> untyped } -> untyped? - end - end - end -end From df12e9e115026ce2b496a8de448d1009c0df60f5 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 20 Oct 2025 19:40:39 -0500 Subject: [PATCH 2/3] remove the tests for those deprecated items --- .../webdriver/bidi/log_inspector_spec.rb | 237 ------------------ 1 file changed, 237 deletions(-) delete mode 100644 rb/spec/integration/selenium/webdriver/bidi/log_inspector_spec.rb diff --git a/rb/spec/integration/selenium/webdriver/bidi/log_inspector_spec.rb b/rb/spec/integration/selenium/webdriver/bidi/log_inspector_spec.rb deleted file mode 100644 index e0d36be936bab..0000000000000 --- a/rb/spec/integration/selenium/webdriver/bidi/log_inspector_spec.rb +++ /dev/null @@ -1,237 +0,0 @@ -# frozen_string_literal: true - -# Licensed to the Software Freedom Conservancy (SFC) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The SFC licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -require_relative '../spec_helper' - -module Selenium - module WebDriver - class BiDi - describe LogInspector, exclusive: {bidi: true, reason: 'only executed when bidi is enabled'}, - only: {browser: %i[chrome edge firefox]} do - let(:page) { 'bidi/logEntryAdded.html' } - - it 'can listen to console log' do - log_entries = [] - log_inspector = described_class.new(driver) - log_inspector.on_console_entry { |log| log_entries << log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'consoleLog').click - log_entry = wait.until { log_entries.find { _1.text == 'Hello, world!' } } - - expect(log_entry).to have_attributes( - text: 'Hello, world!', - realm: nil, - type: 'console', - level: LogInspector::LOG_LEVEL[:INFO], - method: 'log', - args: [{ - 'type' => 'string', - 'value' => 'Hello, world!' - }] - ) - end - - it 'can listen to console log with different consumers' do - log_entries1 = [] - log_entries2 = [] - log_inspector = described_class.new(driver) - log_inspector.on_console_entry { |log| log_entries1 << log } - log_inspector.on_console_entry { |log| log_entries2 << log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'consoleLog').click - log_entry1 = wait.until { log_entries1.find { _1.text == 'Hello, world!' } } - log_entry2 = wait.until { log_entries2.find { _1.text == 'Hello, world!' } } - - expect([log_entry1, log_entry2]).to all( - have_attributes( - text: 'Hello, world!', - realm: nil, - type: 'console', - level: LogInspector::LOG_LEVEL[:INFO], - method: 'log', - args: [{ - 'type' => 'string', - 'value' => 'Hello, world!' - }] - ) - ) - end - - it 'can filter console info level log' do - log_entries = [] - log_inspector = described_class.new(driver) - log_inspector.on_console_entry(FilterBy.log_level('info')) { |log| log_entries << log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'consoleLog').click - log_entry = wait.until { log_entries.find { _1.text == 'Hello, world!' } } - - expect(log_entry).to have_attributes( - text: 'Hello, world!', - realm: nil, - type: 'console', - level: LogInspector::LOG_LEVEL[:INFO], - method: 'log', - args: [{ - 'type' => 'string', - 'value' => 'Hello, world!' - }] - ) - end - - it 'can filter console log' do - log_entries = [] - log_inspector = described_class.new(driver) - log_inspector.on_console_entry(FilterBy.log_level('error')) { |log| log_entries << log } - - driver.navigate.to url_for(page) - # Generating info level log but we are filtering by error level - wait.until { driver.find_element(id: 'consoleLog').displayed? } - driver.find_element(id: 'consoleLog').click - - expect(log_entries).to be_empty - end - - it 'can listen to javascript log' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_javascript_log { |log| log_entry = log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'jsException').click - wait.until { !log_entry.nil? } - - expect(log_entry).to have_attributes( - text: 'Error: Not working', - type: 'javascript', - level: LogInspector::LOG_LEVEL[:ERROR] - ) - end - - it 'can filter javascript log at error level' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_javascript_log(FilterBy.log_level('error')) { |log| log_entry = log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'jsException').click - wait.until { !log_entry.nil? } - - expect(log_entry).to have_attributes( - text: 'Error: Not working', - type: 'javascript', - level: LogInspector::LOG_LEVEL[:ERROR] - ) - end - - it 'can filter javascript log' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_javascript_log(FilterBy.log_level('info')) { |log| log_entry = log } - - driver.navigate.to url_for(page) - # Generating js error level log but we are filtering by info level - wait.until { driver.find_element(id: 'jsException').displayed? } - driver.find_element(id: 'jsException').click - - expect(log_entry).to be_nil - end - - it 'can listen to javascript error log' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_javascript_exception { |log| log_entry = log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'jsException').click - wait.until { !log_entry.nil? } - - expect(log_entry).to have_attributes( - text: 'Error: Not working', - type: 'javascript', - level: LogInspector::LOG_LEVEL[:ERROR] - ) - end - - it 'can listen to any log' do - log_entries = [] - log_inspector = described_class.new(driver) - log_inspector.on_log { |log| log_entries << log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'consoleError').click - log_entry = wait.until { log_entries.find { _1['text'] == 'I am console error' } } - - expect(log_entry).to include( - 'text' => 'I am console error', - 'type' => 'console', - 'level' => LogInspector::LOG_LEVEL[:ERROR] - ) - end - - it 'can filter any log' do - log_entries = [] - log_inspector = described_class.new(driver) - log_inspector.on_log(FilterBy.log_level('info')) { |log| log_entries << log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'consoleLog').click - log_entry = wait.until { log_entries.find { _1['text'] == 'Hello, world!' } } - - expect(log_entry['text']).to eq('Hello, world!') - expect(log_entry['realm']).to be_nil - expect(log_entry['type']).to eq('console') - expect(log_entry['level']).to eq('info') - expect(log_entry['method']).to eq('log') - expect(log_entry['args'].size).to eq(1) - end - - it 'can filter any log at error level' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_log(FilterBy.log_level('error')) { |log| log_entry = log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'jsException').click - wait.until { !log_entry.nil? } - - expect(log_entry['text']).to eq('Error: Not working') - expect(log_entry['type']).to eq('javascript') - expect(log_entry['level']).to eq('error') - end - - it 'can retrieve stack trace for a log' do - log_entry = nil - log_inspector = described_class.new(driver) - log_inspector.on_javascript_log { |log| log_entry = log } - - driver.navigate.to url_for(page) - driver.find_element(id: 'jsException').click - wait.until { !log_entry.nil? } - - stack_trace = log_entry.stack_trace - - expect(stack_trace).not_to be_nil - end - end - end - end -end From 77f2adcef4d246393e3a6f24cb39281873578ed6 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 20 Oct 2025 19:58:31 -0500 Subject: [PATCH 3/3] missed a reference to the spec in the bazel file --- rb/spec/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/rb/spec/BUILD.bazel b/rb/spec/BUILD.bazel index c8be424e1dc48..90e54b85e6422 100644 --- a/rb/spec/BUILD.bazel +++ b/rb/spec/BUILD.bazel @@ -34,7 +34,6 @@ rb_library( "//rb/spec/integration/selenium/webdriver:virtual_authenticator", "//rb/spec/integration/selenium/webdriver:window", "//rb/spec/integration/selenium/webdriver/bidi:browsing_context", - "//rb/spec/integration/selenium/webdriver/bidi:log_inspector", "//rb/spec/integration/selenium/webdriver/bidi:network", "//rb/spec/integration/selenium/webdriver/bidi:script", "//rb/spec/integration/selenium/webdriver/chrome:driver",