Skip to content

Commit 60273d7

Browse files
committed
[rb] create user-friendly method for enabling bidi
1 parent 5761c71 commit 60273d7

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

rb/lib/selenium/webdriver/common/options.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ def add_option(name, value = nil)
9191
@options[name] = value
9292
end
9393

94+
def enable_bidi!
95+
@options[:web_socket_url] = true
96+
end
97+
98+
def bidi?
99+
!!@options[:web_socket_url]
100+
end
101+
94102
def ==(other)
95103
return false unless other.is_a? self.class
96104

rb/spec/integration/selenium/webdriver/chrome/options_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ module Chrome
4343
expect(ua).to eq('foo;bar')
4444
end
4545
end
46+
47+
it 'enables bidi' do
48+
quit_driver
49+
50+
options = Selenium::WebDriver::Options.chrome
51+
expect(options.web_socket_url).to be_nil
52+
expect(options.bidi?).to be false
53+
54+
options.enable_bidi!
55+
expect(options.web_socket_url).to be true
56+
expect(options.bidi?).to be true
57+
58+
driver = Selenium::WebDriver.for :chrome, options: options
59+
60+
expect(driver.capabilities.web_socket_url).to be_a String
61+
62+
driver.quit
63+
end
4664
end
4765
end # Chrome
4866
end # WebDriver

rb/spec/unit/selenium/webdriver/chrome/options_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ module Chrome
141141
end
142142
end
143143

144+
describe '#enable_bidi!' do
145+
it 'allows setting and querying bidi' do
146+
expect(options.web_socket_url).to be_nil
147+
expect(options.bidi?).to be false
148+
149+
options.enable_bidi!
150+
151+
expect(options.bidi?).to be true
152+
expect(options.web_socket_url).to be true
153+
end
154+
end
155+
144156
describe '#add_extension' do
145157
it 'adds an extension' do
146158
allow(File).to receive(:file?).and_return(true)

0 commit comments

Comments
 (0)