diff --git a/rb/lib/selenium/webdriver/common/driver_finder.rb b/rb/lib/selenium/webdriver/common/driver_finder.rb index de8e7572eb610..5fb3e80c5b45a 100644 --- a/rb/lib/selenium/webdriver/common/driver_finder.rb +++ b/rb/lib/selenium/webdriver/common/driver_finder.rb @@ -27,12 +27,14 @@ def results(options, klass) exe = klass::EXECUTABLE if path - validate_files(exe, driver_path: path) + validate_files(driver_path: path) else begin - validate_files(exe, **SeleniumManager.results(to_args(options))) + validate_files(**SeleniumManager.results(to_args(options))) rescue StandardError => e - raise Error::NoSuchDriverError("Unable to obtain #{exe} using Selenium Manager"), e.message, e.backtrace + WebDriver.logger.error("Exception occurred: #{e.message}") + WebDriver.logger.error("Backtrace:\n\t#{e.backtrace&.join("\n\t")}") + raise Error::NoSuchDriverError, "Unable to obtain #{exe} using Selenium Manager" end end end @@ -61,13 +63,9 @@ def to_args(options) args end - def validate_files(exe, **opts) + def validate_files(**opts) opts.each_value do |value| - raise Error::NoSuchDriverError("Unable to locate or obtain #{exe})") if value.nil? - Platform.assert_executable(value) - rescue Error::WebDriverError => e - raise Error::NoSuchDriverError("#{exe} located, but has problems"), e.message, e.backtrace end opts end diff --git a/rb/lib/selenium/webdriver/common/selenium_manager.rb b/rb/lib/selenium/webdriver/common/selenium_manager.rb index d73fa66a9b6a2..35d476b5c379c 100644 --- a/rb/lib/selenium/webdriver/common/selenium_manager.rb +++ b/rb/lib/selenium/webdriver/common/selenium_manager.rb @@ -51,38 +51,31 @@ def results(*arguments) # @return [String] the path to the correct selenium manager def binary @binary ||= begin - location = ENV.fetch('SE_MANAGER_PATH', begin + location = ENV.fetch('SE_MANAGER_PATH', nil) + if location + WebDriver.logger.debug("Selenium Manager set by ENV['SE_MANAGER_PATH']: #{location}") + else directory = File.expand_path(bin_path, __FILE__) - if Platform.windows? - "#{directory}/windows/selenium-manager.exe" - elsif Platform.mac? - "#{directory}/macos/selenium-manager" - elsif Platform.linux? - "#{directory}/linux/selenium-manager" - elsif Platform.unix? - WebDriver.logger.warn('Selenium Manager binary may not be compatible with Unix; verify settings', - id: %i[selenium_manager unix_binary]) - "#{directory}/linux/selenium-manager" - end - rescue Error::WebDriverError => e - raise Error::WebDriverError, "Unable to obtain Selenium Manager binary for #{e.message}" - end) + location = if Platform.windows? + "#{directory}/windows/selenium-manager.exe" + elsif Platform.mac? + "#{directory}/macos/selenium-manager" + elsif Platform.linux? + "#{directory}/linux/selenium-manager" + elsif Platform.unix? + WebDriver.logger.warn('Selenium Manager binary may not be compatible with Unix', + id: %i[selenium_manager unix_binary]) + "#{directory}/linux/selenium-manager" + else + raise Error::WebDriverError, "unsupported platform: #{Platform.os}" + end + WebDriver.logger.debug("Looking for Selenium Manager at: #{location}") + end - validate_location(location) - location - end - end - - def validate_location(location) - raise Error::WebDriverError('Unable to locate or obtain Selenium Manager binary') if value.nil? - - begin Platform.assert_executable(location) - rescue Error::WebDriverError => e - raise Error::WebDriverError, "Selenium Manager binary located, but has problems: #{e.message}" + WebDriver.logger.debug("Selenium Manager binary found at #{location}", id: :selenium_manager) + location end - - WebDriver.logger.debug("Selenium Manager binary found at #{location}", id: :selenium_manager) end def run(*command) @@ -103,7 +96,7 @@ def run(*command) result = json_output['result'] return result unless status.exitstatus.positive? - raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{result}#{stderr}" + raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{result}\n#{stderr}" end end end # SeleniumManager diff --git a/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb index d81dc0080bcc3..4d2bede36d745 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb @@ -45,25 +45,25 @@ def expect_request(body: nil, endpoint: nil) end it 'uses DriverFinder when provided Service without path' do - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) expect_request options = Options.new described_class.new(service: service, options: options) - expect(DriverFinder).to have_received(:path).with(options, service.class) + expect(DriverFinder).to have_received(:results).with(options, service.class) end it 'does not use DriverFinder when provided Service with path' do expect_request allow(service).to receive(:executable_path).and_return('path') - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) described_class.new(service: service) - expect(DriverFinder).not_to have_received(:path) + expect(DriverFinder).not_to have_received(:results) end it 'does not require any parameters' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) @@ -73,7 +73,7 @@ def expect_request(body: nil, endpoint: nil) end it 'accepts provided Options as sole parameter' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) @@ -83,6 +83,14 @@ def expect_request(body: nil, endpoint: nil) expect { described_class.new(options: Options.new(**opts)) }.not_to raise_exception end + it 'raises an ArgumentError if parameter is not recognized' do + allow(DriverFinder).to receive_messages(path: 'path', results: {}) + allow(Platform).to receive(:assert_file) + allow(Platform).to receive(:assert_executable) + msg = 'unknown keyword: :invalid' + expect { described_class.new(invalid: 'foo') }.to raise_error(ArgumentError, msg) + end + it 'does not accept Options of the wrong class' do expect { described_class.new(options: Options.firefox) diff --git a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb index 7ad3581a0563d..55c4e6153e4a0 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb @@ -104,7 +104,7 @@ module Chrome end it 'is created when :url is not provided' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new).and_return(service) @@ -114,7 +114,7 @@ module Chrome end it 'accepts :service without creating a new instance' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new) diff --git a/rb/spec/unit/selenium/webdriver/common/driver_finder_spec.rb b/rb/spec/unit/selenium/webdriver/common/driver_finder_spec.rb index 74405d24b981e..9d6a3ceff1315 100644 --- a/rb/spec/unit/selenium/webdriver/common/driver_finder_spec.rb +++ b/rb/spec/unit/selenium/webdriver/common/driver_finder_spec.rb @@ -22,209 +22,69 @@ module Selenium module WebDriver describe DriverFinder do - context 'when Chrome' do - let(:options) { Options.chrome } - let(:service) { Chrome::Service } - let(:driver) { 'chromedriver' } + it 'class path accepts a String without calling Selenium Manager' do + allow(Chrome::Service).to receive(:driver_path).and_return('path') + allow(SeleniumManager).to receive(:results) + allow(Platform).to receive(:assert_executable) - after { Chrome::Service.driver_path = nil } + described_class.results(Options.chrome, Chrome::Service) - it 'accepts path set on class as String' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = 'path' - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path').exactly(2).times - end - - it 'accepts path set on class as proc' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = proc { 'path' } - - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path') - end - - it 'gives original error if not found by Selenium Manager' do - allow(SeleniumManager).to receive(:driver_path).and_raise(Error::WebDriverError) - - expect { - described_class.path(options, service) - }.to raise_error(WebDriver::Error::NoSuchDriverError, %r{errors/driver_location}) - end + expect(SeleniumManager).not_to have_received(:results) + expect(Platform).to have_received(:assert_executable).with('path') end - context 'when Edge' do - let(:options) { Options.edge } - let(:service) { Edge::Service } - let(:driver) { 'msedgedriver' } - - after { service.driver_path = nil } - - it 'accepts path set on class as String' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = 'path' - described_class.path(options, service) + it 'class path accepts a proc without calling Selenium Manager' do + allow(Chrome::Service).to receive(:driver_path).and_return(proc { 'path' }) + allow(SeleniumManager).to receive(:results) + allow(Platform).to receive(:assert_executable) - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path').exactly(2).times - end + described_class.results(Options.chrome, Chrome::Service) - it 'accepts path set on class as proc' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = proc { 'path' } - - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path') - end - - it 'gives original error if not found by Selenium Manager' do - allow(SeleniumManager).to receive(:driver_path).and_raise(Error::WebDriverError) - - expect { - described_class.path(options, service) - }.to raise_error(WebDriver::Error::NoSuchDriverError, %r{errors/driver_location}) - end + expect(SeleniumManager).not_to have_received(:results) + expect(Platform).to have_received(:assert_executable).with('path') end - context 'when Firefox' do - let(:options) { Options.firefox } - let(:service) { Firefox::Service } - let(:driver) { 'geckodriver' } - - after { service.driver_path = nil } - - it 'accepts path set on class as String' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = 'path' - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path').exactly(2).times - end - - it 'accepts path set on class as proc' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = proc { 'path' } + it 'validates all returned files' do + allow(SeleniumManager).to receive(:results).and_return({browser_path: '/path/to/browser', + driver_path: '/path/to/driver', + anything: '/path/to/random'}) + allow(Platform).to receive(:assert_executable).with('/path/to/browser').and_return(true) + allow(Platform).to receive(:assert_executable).with('/path/to/driver').and_return(true) + allow(Platform).to receive(:assert_executable).with('/path/to/random').and_return(true) - described_class.path(options, service) + described_class.results(Options.chrome, Chrome::Service) - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path') - end - - it 'gives original error if not found by Selenium Manager' do - allow(SeleniumManager).to receive(:driver_path).and_raise(Error::WebDriverError) - - expect { - described_class.path(options, service) - }.to raise_error(WebDriver::Error::NoSuchDriverError, %r{errors/driver_location}) - end + expect(Platform).to have_received(:assert_executable).with('/path/to/browser') + expect(Platform).to have_received(:assert_executable).with('/path/to/driver') + expect(Platform).to have_received(:assert_executable).with('/path/to/random') end - context 'when IE' do - let(:options) { Options.ie } - let(:service) { IE::Service } - let(:driver) { 'IEDriverServer' } - - after { service.driver_path = nil } - - it 'accepts path set on class as String' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = 'path' - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path').exactly(2).times - end - - it 'accepts path set on class as proc' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = proc { 'path' } - - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path') - end - - it 'gives original error if not found by Selenium Manager' do - allow(SeleniumManager).to receive(:driver_path).and_raise(Error::WebDriverError) + it 'wraps error with NoSuchDriverError' do + allow(SeleniumManager).to receive(:results).and_raise(Error::WebDriverError, 'an error') + expect { expect { - described_class.path(options, service) - }.to raise_error(WebDriver::Error::NoSuchDriverError, %r{errors/driver_location}) - end + described_class.results(Options.chrome, Chrome::Service) + }.to output(/Exception occurred: an error/).to_stderr_from_any_process + }.to raise_error(WebDriver::Error::NoSuchDriverError, + /Unable to obtain chromedriver using Selenium Manager; For documentation on this error/) end - context 'when Safari' do - let(:options) { Options.safari } - let(:service) { Safari::Service } - let(:driver) { 'safaridriver' } - - after { service.driver_path = nil } - - it 'accepts path set on class as String' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = 'path' - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path').exactly(2).times - end - - it 'accepts path set on class as proc' do - allow(SeleniumManager).to receive(:driver_path) - allow(Platform).to receive(:assert_file) - allow(Platform).to receive(:assert_executable) - - service.driver_path = proc { 'path' } - - described_class.path(options, service) - - expect(SeleniumManager).not_to have_received(:driver_path) - expect(Platform).to have_received(:assert_executable).with('path') - end - - it 'gives original error if not found by Selenium Manager' do - allow(SeleniumManager).to receive(:driver_path).and_raise(Error::WebDriverError) - - expect { - described_class.path(options, service) - }.to raise_error(WebDriver::Error::NoSuchDriverError, %r{errors/driver_location}) - end + it 'creates arguments' do + allow(SeleniumManager).to receive(:results).and_return({}) + proxy = instance_double(Proxy, ssl: 'proxy') + options = Options.chrome(browser_version: 'stable', proxy: proxy, binary: 'path/to/browser') + + described_class.results(options, Chrome::Service) + + expect(SeleniumManager).to have_received(:results).with(['--browser', + options.browser_name, + '--browser-version', + options.browser_version, + '--browser-path', + options.binary, + '--proxy', + options.proxy.ssl]) end end end diff --git a/rb/spec/unit/selenium/webdriver/common/selenium_manager_spec.rb b/rb/spec/unit/selenium/webdriver/common/selenium_manager_spec.rb index c115c0ab9715f..8ddcc0e38759c 100644 --- a/rb/spec/unit/selenium/webdriver/common/selenium_manager_spec.rb +++ b/rb/spec/unit/selenium/webdriver/common/selenium_manager_spec.rb @@ -23,34 +23,36 @@ module Selenium module WebDriver describe SeleniumManager do describe '.binary' do - def stub_binary(binary) - allow(File).to receive(:exist?).with(a_string_ending_with(binary)).and_return(true) - allow(File).to receive(:executable?).with(a_string_ending_with(binary)).and_return(true) - end - before do described_class.instance_variable_set(:@binary, nil) end + it 'uses environment variable' do + allow(Platform).to receive(:assert_executable).with('/path/to/selenium-manager').and_return(true) + allow(ENV).to receive(:fetch).with('SE_MANAGER_PATH', nil).and_return('/path/to/selenium-manager') + + expect(described_class.send(:binary)).to match(%r{/path/to/selenium-manager}) + end + it 'detects Windows' do - stub_binary('/windows/selenium-manager.exe') - allow(Platform).to receive(:assert_file) + allow(Platform).to receive(:assert_executable).with(a_string_ending_with('/windows/selenium-manager.exe')) + .and_return(true) allow(Platform).to receive(:windows?).and_return(true) expect(described_class.send(:binary)).to match(%r{/windows/selenium-manager\.exe$}) end it 'detects Mac' do - stub_binary('/macos/selenium-manager') - allow(Platform).to receive(:assert_file) + allow(Platform).to receive(:assert_executable).with(a_string_ending_with('/macos/selenium-manager')) + .and_return(true) allow(Platform).to receive_messages(windows?: false, mac?: true) expect(described_class.send(:binary)).to match(%r{/macos/selenium-manager$}) end it 'detects Linux' do - stub_binary('/linux/selenium-manager') - allow(Platform).to receive(:assert_file) + allow(Platform).to receive(:assert_executable).with(a_string_ending_with('/linux/selenium-manager')) + .and_return(true) allow(Platform).to receive_messages(windows?: false, mac?: false, linux?: true) expect(described_class.send(:binary)).to match(%r{/linux/selenium-manager$}) @@ -59,94 +61,44 @@ def stub_binary(binary) it 'errors if cannot find' do allow(File).to receive(:exist?).with(a_string_including('selenium-manager')).and_return(false) - expect { - described_class.send(:binary) - }.to raise_error(Error::WebDriverError, /Selenium Manager binary located, but not a file/) + expect { described_class.send(:binary) }.to raise_error(Error::WebDriverError, /not a file/) end end - describe 'self.run' do - it 'errors if a problem with command' do - expect { - described_class.send(:run, 'anything') - }.to raise_error(Error::WebDriverError, /Unsuccessful command executed: /) - end - end - - describe 'self.driver_path' do - it 'determines browser name by default' do - allow(described_class).to receive_messages(run: {'browser_path' => '', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - - described_class.driver_path(Options.chrome) - - expect(described_class).to have_received(:run) - .with('selenium-manager', '--browser', 'chrome') - end - - it 'uses browser version if specified' do - allow(described_class).to receive_messages(run: {'browser_path' => '', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - options = Options.chrome(browser_version: 1) - - described_class.driver_path(options) - - expect(described_class).to have_received(:run) - .with('selenium-manager', - '--browser', 'chrome', - '--browser-version', 1) - end - - it 'uses proxy if specified' do - proxy = Selenium::WebDriver::Proxy.new(ssl: 'proxy') - allow(described_class).to receive_messages(run: {'browser_path' => '', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - options = Options.chrome(proxy: proxy) - - described_class.driver_path(options) + describe '.run' do + it 'returns result if positive exit status' do + status = instance_double(Process::Status, exitstatus: 0) + stdout = '{"result": "value"}' + allow(Open3).to receive(:capture3).and_return([stdout, 'stderr', status]) - expect(described_class).to have_received(:run) - .with('selenium-manager', - '--browser', 'chrome', - '--proxy', 'proxy') + expect(described_class.send(:run, 'anything')).to eq 'value' end - it 'uses browser location if specified' do - allow(described_class).to receive_messages(run: {'browser_path' => '', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - options = Options.chrome(binary: '/path/to/browser') - - described_class.driver_path(options) + it 'errors if a problem with command' do + allow(Open3).to receive(:capture3).and_raise(StandardError) - expect(described_class).to have_received(:run) - .with('selenium-manager', '--browser', 'chrome', '--browser-path', '/path/to/browser') + expect { + described_class.send(:run, 'anything') + }.to raise_error(Error::WebDriverError, /Unsuccessful command executed: \["anything"\]/) end - it 'properly escapes plain spaces in browser location' do - allow(described_class).to receive_messages(run: {'browser_path' => 'a', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - options = Options.chrome(binary: '/path to/the/browser') + it 'errors if exit status greater than 0' do + status = instance_double(Process::Status, exitstatus: 1) + stdout = '{"result": "value"}' + allow(Open3).to receive(:capture3).and_return([stdout, 'stderr', status]) - described_class.driver_path(options) - - expect(described_class).to have_received(:run) - .with('selenium-manager', '--browser', 'chrome', - '--browser-path', '/path to/the/browser') + expect { + described_class.send(:run, 'anything') + }.to raise_error(Error::WebDriverError, /Unsuccessful command executed: \["anything"\]\nvalue\nstderr/) end + end - it 'sets binary location on options' do - allow(described_class).to receive_messages(run: {'browser_path' => 'foo', 'driver_path' => ''}, - binary: 'selenium-manager') - allow(Platform).to receive(:assert_executable) - options = Options.chrome - - described_class.driver_path(options) - expect(options.binary).to eq 'foo' + describe '.results' do + it 'returns asset paths' do + allow(described_class).to receive_messages(binary: 'binary', run: {'browser_path' => '/path/to/browser', + 'driver_path' => '/path/to/driver'}) + expect(described_class.results('something')).to eq({browser_path: '/path/to/browser', + driver_path: '/path/to/driver'}) end end end diff --git a/rb/spec/unit/selenium/webdriver/edge/driver_spec.rb b/rb/spec/unit/selenium/webdriver/edge/driver_spec.rb index bbf3fd7219a17..aee473f684987 100644 --- a/rb/spec/unit/selenium/webdriver/edge/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/edge/driver_spec.rb @@ -46,33 +46,34 @@ def expect_request(body: nil, endpoint: nil) it 'uses DriverFinder when provided Service without path' do expect_request - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) options = Options.new described_class.new(service: service, options: options) - expect(DriverFinder).to have_received(:path).with(options, service.class) + expect(DriverFinder).to have_received(:results).with(options, service.class) end it 'does not use DriverFinder when provided Service with path' do expect_request allow(service).to receive(:executable_path).and_return('path') - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) described_class.new(service: service) - expect(DriverFinder).not_to have_received(:path) + expect(DriverFinder).not_to have_received(:results) end it 'does not require any parameters' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) + expect_request expect { described_class.new }.not_to raise_exception end it 'accepts provided Options as sole parameter' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) opts = {args: ['-f']} @@ -82,7 +83,7 @@ def expect_request(body: nil, endpoint: nil) end it 'raises an ArgumentError if parameter is not recognized' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) msg = 'unknown keyword: :invalid' diff --git a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb index 9f45e5c58c5ff..9011f7f7c792b 100644 --- a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb @@ -107,7 +107,7 @@ module Edge end it 'is created when :url is not provided' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new).and_return(service) @@ -117,7 +117,7 @@ module Edge end it 'accepts :service without creating a new instance' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new) diff --git a/rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb index e04a0de6ab72f..b3769db948ede 100644 --- a/rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/firefox/driver_spec.rb @@ -49,24 +49,24 @@ def expect_request(body: nil, endpoint: nil) it 'uses DriverFinder when provided Service without path' do expect_request - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) options = Options.new described_class.new(service: service, options: options) - expect(DriverFinder).to have_received(:path).with(options, service.class) + expect(DriverFinder).to have_received(:results).with(options, service.class) end it 'does not use DriverFinder when provided Service with path' do expect_request allow(service).to receive(:executable_path).and_return('path') - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) described_class.new(service: service) - expect(DriverFinder).not_to have_received(:path) + expect(DriverFinder).not_to have_received(:results) end it 'does not require any parameters' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) expect_request @@ -75,7 +75,7 @@ def expect_request(body: nil, endpoint: nil) end it 'accepts provided Options as sole parameter' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) diff --git a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb index 3fd004bf20bd5..abbc67aae4b62 100644 --- a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb @@ -100,7 +100,7 @@ module Firefox end it 'is created when :url is not provided' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new).and_return(service) @@ -111,7 +111,7 @@ module Firefox end it 'accepts :service without creating a new instance' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new) diff --git a/rb/spec/unit/selenium/webdriver/ie/driver_spec.rb b/rb/spec/unit/selenium/webdriver/ie/driver_spec.rb index d3698eb13bc26..bb3f08ac83f49 100644 --- a/rb/spec/unit/selenium/webdriver/ie/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/ie/driver_spec.rb @@ -47,24 +47,24 @@ def expect_request(body: nil, endpoint: nil) it 'uses DriverFinder when provided Service without path' do expect_request - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) options = Options.new described_class.new(service: service, options: options) - expect(DriverFinder).to have_received(:path).with(options, service.class) + expect(DriverFinder).to have_received(:results).with(options, service.class) end it 'does not use DriverFinder when provided Service with path' do expect_request allow(service).to receive(:executable_path).and_return('path') - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) described_class.new(service: service) - expect(DriverFinder).not_to have_received(:path) + expect(DriverFinder).not_to have_received(:results) end it 'does not require any parameters' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) expect_request @@ -73,7 +73,7 @@ def expect_request(body: nil, endpoint: nil) end it 'accepts provided Options as sole parameter' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) opts = {args: ['-f']} diff --git a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb index f27dbdbbaeb01..b27619975ad19 100644 --- a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb @@ -102,7 +102,7 @@ module IE end it 'is created when :url is not provided' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new).and_return(service) @@ -113,7 +113,7 @@ module IE end it 'accepts :service without creating a new instance' do - allow(DriverFinder).to receive(:path).and_return('path') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new) diff --git a/rb/spec/unit/selenium/webdriver/safari/driver_spec.rb b/rb/spec/unit/selenium/webdriver/safari/driver_spec.rb index f88f8cacdf483..07aeaacaaaebd 100644 --- a/rb/spec/unit/selenium/webdriver/safari/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/safari/driver_spec.rb @@ -46,24 +46,24 @@ def expect_request(body: nil, endpoint: nil) it 'uses DriverFinder when provided Service without path' do expect_request - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) options = Options.new described_class.new(service: service, options: options) - expect(DriverFinder).to have_received(:path).with(options, service.class) + expect(DriverFinder).to have_received(:results).with(options, service.class) end it 'does not use DriverFinder when provided Service with path' do expect_request allow(service).to receive(:executable_path).and_return('path') - allow(DriverFinder).to receive(:path) + allow(DriverFinder).to receive(:results).and_return({}) described_class.new(service: service) - expect(DriverFinder).not_to have_received(:path) + expect(DriverFinder).not_to have_received(:results) end it 'does not require any parameters' do - allow(DriverFinder).to receive(:path).and_return('/path/to/safaridriver') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) expect_request @@ -72,7 +72,7 @@ def expect_request(body: nil, endpoint: nil) end it 'accepts provided Options as sole parameter' do - allow(DriverFinder).to receive(:path).and_return('/path/to/safaridriver') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) opts = {automatic_inspection: true} diff --git a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb index df79bffdac671..1d67f509e92c0 100644 --- a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb @@ -97,7 +97,7 @@ module Safari end it 'is created when :url is not provided' do - allow(DriverFinder).to receive(:path).and_return('/path/to/safaridriver') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new).and_return(service) @@ -108,7 +108,7 @@ module Safari end it 'accepts :service without creating a new instance' do - allow(DriverFinder).to receive(:path).and_return('/path/to/safaridriver') + allow(DriverFinder).to receive(:results).and_return({}) allow(Platform).to receive(:assert_file) allow(Platform).to receive(:assert_executable) allow(described_class).to receive(:new)