Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8c317d8
[build] allow tests tagged exclusive-if-local to run on rbe
titusfortner Mar 22, 2025
bb29c66
merge trunk
aguspe Apr 2, 2025
5b6a0ce
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 22, 2025
c9cb77c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Apr 30, 2025
ac9a80e
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 18, 2025
aef922a
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe May 24, 2025
8dc6cfc
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 7, 2025
16dc0d3
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jun 13, 2025
85fdc1c
Merge branch 'trunk' of github.com:aguspe/selenium into trunk
aguspe Jul 14, 2025
41e2533
Adding options
aguspe Jul 14, 2025
69847e9
Pass waits to bidi bridge
aguspe Jul 16, 2025
b81bfed
Add tests and modify options
aguspe Jul 17, 2025
6d363dd
fix test
aguspe Jul 19, 2025
ff4f51e
Merge branch 'trunk' into rb_make_bidi_timeout_configurable
aguspe Jul 19, 2025
30fa9b8
rollback driver changes
aguspe Jul 19, 2025
eaa2d03
Merge remote-tracking branch 'origin/rb_make_bidi_timeout_configurabl…
aguspe Jul 19, 2025
1d46033
Merge branch 'trunk' into rb_make_bidi_timeout_configurable
aguspe Aug 2, 2025
4fb9290
Merge branch 'trunk' into rb_make_bidi_timeout_configurable
aguspe Aug 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/bidi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class BiDi
autoload :InterceptedAuth, 'selenium/webdriver/bidi/network/intercepted_auth'
autoload :InterceptedItem, 'selenium/webdriver/bidi/network/intercepted_item'

def initialize(url:)
@ws = WebSocketConnection.new(url: url)
def initialize(url:, **)
@ws = WebSocketConnection.new(url: url, **)
end

def close
Expand Down
6 changes: 5 additions & 1 deletion rb/lib/selenium/webdriver/common/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Options

GRID_OPTIONS = %i[enable_downloads].freeze

WEBSOCKET_OPTIONS = %i[web_socket_timeout web_socket_interval].freeze

class << self
attr_reader :driver_path

Expand All @@ -52,7 +54,7 @@ def safari(**)
end

def set_capabilities
(W3C_OPTIONS + GRID_OPTIONS + self::CAPABILITIES.keys).each do |key|
(W3C_OPTIONS + GRID_OPTIONS + WEBSOCKET_OPTIONS + self::CAPABILITIES.keys).each do |key|
next if method_defined? key

define_method key do
Expand Down Expand Up @@ -108,6 +110,8 @@ def as_json(*)

downloads = options.delete(:enable_downloads)
options['se:downloadsEnabled'] = downloads unless downloads.nil?
options['ws:response_timeout'] = options.delete(:web_socket_timeout) if options[:web_socket_timeout]
options['ws:response_interval'] = options.delete(:web_socket_interval) if options[:web_socket_interval]
w3c_options = process_w3c_options(options)

browser_options = self.class::CAPABILITIES.each_with_object({}) do |(capability_alias, capability_name), hash|
Expand Down
7 changes: 5 additions & 2 deletions rb/lib/selenium/webdriver/common/websocket_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ class WebSocketConnection

MAX_LOG_MESSAGE_SIZE = 9999

def initialize(url:)
def initialize(url:, options: {})
@callback_threads = ThreadGroup.new

@response_timeout = options.fetch(:response_timeout, RESPONSE_WAIT_TIMEOUT)
@response_interval = options.fetch(:response_interval, RESPONSE_WAIT_INTERVAL)

@session_id = nil
@url = url

Expand Down Expand Up @@ -147,7 +150,7 @@ def callback_thread(params)
end

def wait
@wait ||= Wait.new(timeout: RESPONSE_WAIT_TIMEOUT, interval: RESPONSE_WAIT_INTERVAL)
@wait ||= Wait.new(timeout: @response_timeout, interval: @response_interval)
end

def socket
Expand Down
8 changes: 7 additions & 1 deletion rb/lib/selenium/webdriver/remote/bidi_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ class BiDiBridge < Bridge
def create_session(capabilities)
super
socket_url = @capabilities[:web_socket_url]
@bidi = Selenium::WebDriver::BiDi.new(url: socket_url)

ws_options = {
response_timeout: capabilities['ws:responseTimeout'],
response_interval: capabilities['ws:responseInterval']
}.compact

@bidi = Selenium::WebDriver::BiDi.new(url: socket_url, options: ws_options)
end

def get(url)
Expand Down
2 changes: 2 additions & 0 deletions rb/sig/lib/selenium/webdriver/common/websocket_connection.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Selenium

@callback_threads: untyped

@response_interval: Float
@response_timeout: Integer
@session_id: untyped

@url: untyped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ class BiDi
browsing_context.activate
expect(driver.execute_script('return document.hasFocus();')).to be_truthy
end

it 'times out if a command takes too long' do
reset_driver!(web_socket_url: true, web_socket_timeout: 0.1, web_socket_interval: 1) do |driver|
expect {
driver.navigate.to url_for('sleep?time=0.2')
}.to raise_error(Selenium::WebDriver::Error::TimeoutError)
end
end
end
end # BiDi
end # WebDriver
Expand Down
Loading