Skip to content

Let firefox choose the bidi port by default #15727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/firefox/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Service < WebDriver::Service

def initialize(path: nil, port: nil, log: nil, args: nil)
args ||= []
unless args.any? { |arg| arg.include?('--connect-existing') }
unless args.any? { |arg| arg.include?('--connect-existing') || arg.include?('--websocket-port') }
args << '--websocket-port'
args << WebDriver::PortProber.above(9222).to_s
args << '0'
end
super
end
Expand Down
15 changes: 0 additions & 15 deletions rb/spec/integration/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ module Firefox
it 'can be started outside driver' do
expect(service_manager.uri).to be_a(URI)
end

context 'with BiDi enabled', exclusive: {bidi: true, reason: 'only executed when bidi is enabled'} do
it 'ensures two service instances use different websocket port' do
service1 = described_class.new
service2 = described_class.new

ws_index1 = service1.args.index('--websocket-port')
ws_index2 = service2.args.index('--websocket-port')

port1 = service1.args[ws_index1 + 1].to_i
port2 = service2.args[ws_index2 + 1].to_i

expect(port1).not_to eq(port2)
end
end
end
end # Firefox
end # WebDriver
Expand Down
12 changes: 10 additions & 2 deletions rb/spec/unit/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ module Firefox
expect(service.extra_args).to include(*%w[--foo --bar])
end

it 'there is a random port for websocket' do
it 'there is a zero port for websocket' do
service = described_class.new
ws_index = service.extra_args.index('--websocket-port')
port = service.extra_args[ws_index + 1].to_i
expect(port).to be_positive
expect(port).to be_zero
end

context 'with connect existing' do
Expand All @@ -91,6 +91,14 @@ module Firefox
expect(service.extra_args).to eq(['--connect-existing'])
end
end

context 'with websocket port' do
it 'does not add websocket-port' do
service = described_class.new(args: ['--websocket-port=1234'])
expect(service.extra_args).not_to include('--websocket-port=0')
expect(service.extra_args).to eq(['--websocket-port=1234'])
end
end
end

context 'when initializing driver' do
Expand Down
Loading