Skip to content
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
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/local_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize_local_driver(options, service, url, http_client, client_config)

begin
yield(caps, http_client) if block_given?
rescue Selenium::WebDriver::Error::WebDriverError
rescue StandardError
@service_manager&.stop
raise
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
end
Expand Down
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/common/service_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def stop

stop_server
@process.poll_for_exit STOP_TIMEOUT
rescue ChildProcess::TimeoutError, Errno::ECONNREFUSED
rescue ChildProcess::TimeoutError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE,
Net::OpenTimeout, Net::ReadTimeout, EOFError
nil # noop
ensure
stop_process
Expand Down
2 changes: 2 additions & 0 deletions rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ def expect_request(body: nil, endpoint: nil)

it 'raises an ArgumentError if parameter is not recognized' do
allow(DriverFinder).to receive(:new).and_return(finder)
allow(service_manager).to receive(:stop)

msg = 'unknown keyword: :invalid'
expect { described_class.new(invalid: 'foo') }.to raise_error(ArgumentError, msg)
expect(service_manager).to have_received(:stop)
end

it 'does not accept Options of the wrong class' do
Expand Down
2 changes: 2 additions & 0 deletions rb/spec/unit/selenium/webdriver/edge/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def expect_request(body: nil, endpoint: nil)

it 'raises an ArgumentError if parameter is not recognized' do
allow(DriverFinder).to receive(:new).and_return(finder)
allow(service_manager).to receive(:stop)
msg = 'unknown keyword: :invalid'
expect { described_class.new(invalid: 'foo') }.to raise_error(ArgumentError, msg)
expect(service_manager).to have_received(:stop)
end

it 'does not accept Options of the wrong class' do
Expand Down
9 changes: 9 additions & 0 deletions rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ def expect_request(body: nil, endpoint: nil)
expect { described_class.new(options: Options.new(**opts)) }.not_to raise_exception
end

it 'stops the driver service when starting the session times out' do
allow(DriverFinder).to receive(:new).and_return(finder)
allow(service_manager).to receive(:stop)
stub_request(:post, "#{service_manager.uri}/session").to_raise(Net::ReadTimeout)

expect { described_class.new }.to raise_exception(Net::ReadTimeout)
expect(service_manager).to have_received(:stop)
end

it 'does not accept Options of the wrong class' do
expect {
described_class.new(options: Options.chrome)
Expand Down
Loading