Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
10 changes: 10 additions & 0 deletions rb/lib/selenium/webdriver/common/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def set_capabilities
def initialize(**opts)
self.class.set_capabilities

opts[:web_socket_url] = opts.delete(:bidi) if opts.key?(:bidi)

@options = opts
@options[:browser_name] = self.class::BROWSER
end
Expand All @@ -91,6 +93,14 @@ def add_option(name, value = nil)
@options[name] = value
end

def enable_bidi!
Comment thread
p0deje marked this conversation as resolved.
@options[:web_socket_url] = true
end

def bidi?
!!@options[:web_socket_url]
end

def ==(other)
return false unless other.is_a? self.class

Expand Down
4 changes: 4 additions & 0 deletions rb/sig/lib/selenium/webdriver/common/options.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ module Selenium

def ==: (untyped other) -> bool

def bidi?: -> bool

def enable_bidi!: -> bool

alias eql? ==

def as_json: (*untyped) -> untyped
Expand Down
32 changes: 32 additions & 0 deletions rb/spec/integration/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,38 @@ module Chrome
expect(ua).to eq('foo;bar')
end
end

it 'enables bidi' do
quit_driver

options = Selenium::WebDriver::Options.chrome
expect(options.web_socket_url).to be_nil
expect(options.bidi?).to be false

options.enable_bidi!
expect(options.web_socket_url).to be true
expect(options.bidi?).to be true

driver = Selenium::WebDriver.for :chrome, options: options

expect(driver.capabilities.web_socket_url).to be_a String

driver.quit
end

it 'enables BiDi on initialization' do
quit_driver

options = Selenium::WebDriver::Options.chrome(bidi: true)
expect(options.web_socket_url).to be true
expect(options.bidi?).to be true

driver = Selenium::WebDriver.for :chrome, options: options

expect(driver.capabilities.web_socket_url).to be_a String

driver.quit
end
end
end # Chrome
end # WebDriver
Expand Down
32 changes: 32 additions & 0 deletions rb/spec/integration/selenium/webdriver/edge/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,38 @@ module Edge
expect(ua).to eq('foo;bar')
end
end

it 'enables bidi' do
quit_driver

options = Selenium::WebDriver::Options.chrome
expect(options.web_socket_url).to be_nil
expect(options.bidi?).to be false

options.enable_bidi!
expect(options.web_socket_url).to be true
expect(options.bidi?).to be true

driver = Selenium::WebDriver.for :chrome, options: options

expect(driver.capabilities.web_socket_url).to be_a String

driver.quit
end

it 'enables BiDi on initialization' do
quit_driver

options = Selenium::WebDriver::Options.edge(bidi: true)
expect(options.web_socket_url).to be true
expect(options.bidi?).to be true

driver = Selenium::WebDriver.for :edge, options: options

expect(driver.capabilities.web_socket_url).to be_a String

driver.quit
end
end
end # Edge
end # WebDriver
Expand Down
12 changes: 12 additions & 0 deletions rb/spec/unit/selenium/webdriver/chrome/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ module Chrome
end
end

describe '#enable_bidi!' do
it 'allows setting and querying bidi' do
expect(options.web_socket_url).to be_nil
expect(options.bidi?).to be false

options.enable_bidi!

expect(options.bidi?).to be true
expect(options.web_socket_url).to be true
end
end

describe '#add_extension' do
it 'adds an extension' do
allow(File).to receive(:file?).and_return(true)
Expand Down
Loading