Skip to content

[rb] Add websocket-port parameter to firefox service #15458

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 22 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
03d36c9
Add --websocket-port parameter to firefox service
aguspe Mar 19, 2025
532901d
Correct identation issue
aguspe Mar 19, 2025
8f30cbe
Add guard to test
aguspe Mar 19, 2025
8a06214
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 19, 2025
7f9eacb
Improve unit test
aguspe Mar 19, 2025
9341f70
Merge remote-tracking branch 'origin/rb_add_argument_for_websocket_po…
aguspe Mar 19, 2025
6d94f0e
Improve unit test
aguspe Mar 19, 2025
b2bd960
fix identation
aguspe Mar 19, 2025
82caee4
Simplifying test and fixing formatting issue
aguspe Mar 19, 2025
360c7b6
Simplifying test and fixing formatting issue
aguspe Mar 19, 2025
58cfb2e
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 20, 2025
f93a1f5
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 20, 2025
3062d0e
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 20, 2025
ea89793
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 21, 2025
0765208
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 21, 2025
63c1bd7
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 26, 2025
56485c7
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Mar 27, 2025
7b26610
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Apr 7, 2025
5872b2d
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Apr 12, 2025
6d808e8
Use the PortProber isntead of Sockets
aguspe Apr 12, 2025
c45777c
Merge branch 'trunk' into rb_add_argument_for_websocket_port
aguspe Apr 29, 2025
2aba2ab
Change port to 9222
aguspe Apr 29, 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
9 changes: 9 additions & 0 deletions rb/lib/selenium/webdriver/firefox/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class Service < WebDriver::Service
EXECUTABLE = 'geckodriver'
SHUTDOWN_SUPPORTED = false
DRIVER_PATH_ENV_KEY = 'SE_GECKODRIVER'

def initialize(path: nil, port: nil, log: nil, args: nil)
args ||= []
unless args.any? { |arg| arg.include?('--connect-existing') }
args << '--websocket-port'
args << WebDriver::PortProber.above(9222).to_s
end
super
end
end # Service
end # Firefox
end # WebDriver
Expand Down
15 changes: 15 additions & 0 deletions rb/spec/integration/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ 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
20 changes: 17 additions & 3 deletions rb/spec/unit/selenium/webdriver/firefox/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module Firefox
it 'does not create args by default' do
service = described_class.new

expect(service.extra_args).to be_empty
expect(service.extra_args.count).to eq 2
end

it 'uses sets log path to stdout' do
Expand All @@ -73,9 +73,23 @@ module Firefox
end

it 'uses provided args' do
service = described_class.new(args: ['--foo', '--bar'])
service = described_class.new(args: %w[--foo --bar])
expect(service.extra_args).to include(*%w[--foo --bar])
end

expect(service.extra_args).to eq ['--foo', '--bar']
it 'there is a random 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
end

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

Expand Down
Loading