Skip to content

Commit 49fb529

Browse files
committed
[rb] accommodate Driver Finder being sent something other than an Options instance
1 parent a9ac837 commit 49fb529

6 files changed

Lines changed: 12 additions & 4 deletions

File tree

rb/lib/selenium/webdriver/common/driver_finder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.path(options, klass)
2727

2828
path ||= begin
2929
SeleniumManager.driver_path(options)
30-
rescue Error::WebDriverError => e
30+
rescue StandardError => e
3131
WebDriver.logger.debug("Unable obtain driver using Selenium Manager\n #{e.message}")
3232
nil
3333
end

rb/lib/selenium/webdriver/common/selenium_manager.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class << self
3333
# @param [Options] options browser options.
3434
# @return [String] the path to the correct driver.
3535
def driver_path(options)
36-
message = "driver for #{options.browser_name} not found; attempting to install with Selenium Manager"
36+
message = 'applicable driver not found; attempting to install with Selenium Manager'
3737
WebDriver.logger.warn(message)
3838

3939
unless options.is_a?(Options)
40-
raise ArgumentError, "SeleniumManager requires a WebDriver::Options instance, not a #{options.inspect}"
40+
raise ArgumentError, "SeleniumManager requires a WebDriver::Options instance, not #{options.inspect}"
4141
end
4242

4343
command = [binary, '--browser', options.browser_name, '--output', 'json']

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def expect_request(body: nil, endpoint: nil)
4545
end
4646

4747
it 'uses DriverFinder when provided Service without path' do
48-
expect_request
4948
allow(DriverFinder).to receive(:path)
49+
expect_request
5050
options = Options.new
5151

5252
described_class.new(service: service, options: options)
@@ -96,6 +96,8 @@ def expect_request(body: nil, endpoint: nil)
9696
end
9797

9898
context 'with :capabilities' do
99+
before { allow(DriverFinder).to receive(:path) }
100+
99101
it 'accepts value as a Symbol' do
100102
expect_request
101103
expect { described_class.new(capabilities: :chrome) }.to have_deprecated(:capabilities)

rb/spec/unit/selenium/webdriver/edge/driver_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ def expect_request(body: nil, endpoint: nil)
101101
end
102102

103103
context 'with :capabilities' do
104+
before { allow(DriverFinder).to receive(:path) }
105+
104106
it 'accepts value as a Symbol' do
105107
expect_request
106108
expect {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def expect_request(body: nil, endpoint: nil)
100100
end
101101

102102
context 'with :capabilities' do
103+
before { allow(DriverFinder).to receive(:path) }
104+
103105
it 'accepts value as a Symbol' do
104106
expect_request
105107
expect { described_class.new(capabilities: :firefox) }.to have_deprecated(:capabilities)

rb/spec/unit/selenium/webdriver/ie/driver_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def expect_request(body: nil, endpoint: nil)
9898
end
9999

100100
context 'with :capabilities' do
101+
before { allow(DriverFinder).to receive(:path) }
102+
101103
it 'accepts value as a Symbol' do
102104
expect_request
103105
expect { described_class.new(capabilities: :ie) }.to have_deprecated(:capabilities)

0 commit comments

Comments
 (0)