Skip to content

Commit 1e2945d

Browse files
tomhughesaguspe
andauthored
Let firefox choose the bidi port by default (#15727)
If the user hasn't asked for a specific port then just let firefox choose a random one. Co-authored-by: Augustin Gottlieb <[email protected]>
1 parent f359e61 commit 1e2945d

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

rb/lib/selenium/webdriver/firefox/service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ class Service < WebDriver::Service
2828

2929
def initialize(path: nil, port: nil, log: nil, args: nil)
3030
args ||= []
31-
unless args.any? { |arg| arg.include?('--connect-existing') }
31+
unless args.any? { |arg| arg.include?('--connect-existing') || arg.include?('--websocket-port') }
3232
args << '--websocket-port'
33-
args << WebDriver::PortProber.above(9222).to_s
33+
args << '0'
3434
end
3535
super
3636
end

rb/spec/integration/selenium/webdriver/firefox/service_spec.rb

-15
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@ module Firefox
3939
it 'can be started outside driver' do
4040
expect(service_manager.uri).to be_a(URI)
4141
end
42-
43-
context 'with BiDi enabled', exclusive: {bidi: true, reason: 'only executed when bidi is enabled'} do
44-
it 'ensures two service instances use different websocket port' do
45-
service1 = described_class.new
46-
service2 = described_class.new
47-
48-
ws_index1 = service1.args.index('--websocket-port')
49-
ws_index2 = service2.args.index('--websocket-port')
50-
51-
port1 = service1.args[ws_index1 + 1].to_i
52-
port2 = service2.args[ws_index2 + 1].to_i
53-
54-
expect(port1).not_to eq(port2)
55-
end
56-
end
5742
end
5843
end # Firefox
5944
end # WebDriver

rb/spec/unit/selenium/webdriver/firefox/service_spec.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ module Firefox
7777
expect(service.extra_args).to include(*%w[--foo --bar])
7878
end
7979

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

8787
context 'with connect existing' do
@@ -91,6 +91,14 @@ module Firefox
9191
expect(service.extra_args).to eq(['--connect-existing'])
9292
end
9393
end
94+
95+
context 'with websocket port' do
96+
it 'does not add websocket-port' do
97+
service = described_class.new(args: ['--websocket-port=1234'])
98+
expect(service.extra_args).not_to include('--websocket-port=0')
99+
expect(service.extra_args).to eq(['--websocket-port=1234'])
100+
end
101+
end
94102
end
95103

96104
context 'when initializing driver' do

0 commit comments

Comments
 (0)