From d3af87c35b0624b4a0b296b79e48833d4131f9b2 Mon Sep 17 00:00:00 2001 From: aguspe Date: Sat, 20 Jul 2024 10:11:32 +0200 Subject: [PATCH 01/10] Add ENV variables for path --- rb/lib/selenium/webdriver/chrome/service.rb | 1 + rb/lib/selenium/webdriver/common/service.rb | 1 + rb/lib/selenium/webdriver/edge/service.rb | 2 +- rb/lib/selenium/webdriver/firefox/service.rb | 1 + rb/lib/selenium/webdriver/ie/service.rb | 1 + rb/lib/selenium/webdriver/safari/service.rb | 2 +- 6 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rb/lib/selenium/webdriver/chrome/service.rb b/rb/lib/selenium/webdriver/chrome/service.rb index 82945bba8964a..a927cb659adbe 100644 --- a/rb/lib/selenium/webdriver/chrome/service.rb +++ b/rb/lib/selenium/webdriver/chrome/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'chromedriver' SHUTDOWN_SUPPORTED = true + PATH = ENV.fetch('SE_CHROMEDRIVER', nil) def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/common/service.rb b/rb/lib/selenium/webdriver/common/service.rb index e20f7569db28c..53d688e15b9ef 100644 --- a/rb/lib/selenium/webdriver/common/service.rb +++ b/rb/lib/selenium/webdriver/common/service.rb @@ -69,6 +69,7 @@ def driver_path=(path) def initialize(path: nil, port: nil, log: nil, args: nil) port ||= self.class::DEFAULT_PORT args ||= [] + path ||= self.class::PATH @executable_path = path @host = Platform.localhost diff --git a/rb/lib/selenium/webdriver/edge/service.rb b/rb/lib/selenium/webdriver/edge/service.rb index 7b4ca72ecba27..ef512aaeedaba 100644 --- a/rb/lib/selenium/webdriver/edge/service.rb +++ b/rb/lib/selenium/webdriver/edge/service.rb @@ -24,7 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'msedgedriver' SHUTDOWN_SUPPORTED = true - + PATH = ENV.fetch('SE_EDGEDRIVER', nil) def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/firefox/service.rb b/rb/lib/selenium/webdriver/firefox/service.rb index 44f449f2a60d3..07ac63720a480 100644 --- a/rb/lib/selenium/webdriver/firefox/service.rb +++ b/rb/lib/selenium/webdriver/firefox/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 4444 EXECUTABLE = 'geckodriver' SHUTDOWN_SUPPORTED = false + PATH = ENV.fetch('SE_IEDRIVER', nil) end # Service end # Firefox end # WebDriver diff --git a/rb/lib/selenium/webdriver/ie/service.rb b/rb/lib/selenium/webdriver/ie/service.rb index 079d1e0341113..5e8d963c4146b 100644 --- a/rb/lib/selenium/webdriver/ie/service.rb +++ b/rb/lib/selenium/webdriver/ie/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 5555 EXECUTABLE = 'IEDriverServer' SHUTDOWN_SUPPORTED = true + PATH = ENV.fetch('SE_IEDRIVER', nil) end # Server end # IE end # WebDriver diff --git a/rb/lib/selenium/webdriver/safari/service.rb b/rb/lib/selenium/webdriver/safari/service.rb index f720b21d4ea70..39534014b5c17 100644 --- a/rb/lib/selenium/webdriver/safari/service.rb +++ b/rb/lib/selenium/webdriver/safari/service.rb @@ -24,7 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 7050 EXECUTABLE = 'safaridriver' SHUTDOWN_SUPPORTED = false - + PATH = ENV.fetch('SE_SAFARIDRIVER', nil) def initialize(path: nil, port: nil, log: nil, args: nil) raise Error::WebDriverError, 'Safari Service does not support setting log output' if log From 13f03366fd5b8655169202dc0adf315b5e567407 Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 30 Aug 2024 15:04:49 +0200 Subject: [PATCH 02/10] Update RBS and gecko driver --- rb/lib/selenium/webdriver/firefox/service.rb | 2 +- rb/sig/lib/selenium/webdriver/chrome/service.rbs | 2 ++ rb/sig/lib/selenium/webdriver/edge/service.rbs | 2 ++ rb/sig/lib/selenium/webdriver/firefox/service.rbs | 1 + rb/sig/lib/selenium/webdriver/ie/service.rbs | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rb/lib/selenium/webdriver/firefox/service.rb b/rb/lib/selenium/webdriver/firefox/service.rb index 07ac63720a480..b2d3285080335 100644 --- a/rb/lib/selenium/webdriver/firefox/service.rb +++ b/rb/lib/selenium/webdriver/firefox/service.rb @@ -24,7 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 4444 EXECUTABLE = 'geckodriver' SHUTDOWN_SUPPORTED = false - PATH = ENV.fetch('SE_IEDRIVER', nil) + PATH = ENV.fetch('SE_GECKODRIVER', nil) end # Service end # Firefox end # WebDriver diff --git a/rb/sig/lib/selenium/webdriver/chrome/service.rbs b/rb/sig/lib/selenium/webdriver/chrome/service.rbs index a94d9c8d4900c..579323dc508b2 100644 --- a/rb/sig/lib/selenium/webdriver/chrome/service.rbs +++ b/rb/sig/lib/selenium/webdriver/chrome/service.rbs @@ -2,6 +2,8 @@ module Selenium module WebDriver module Chrome class Service < WebDriver::Service + PATH: String + @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/edge/service.rbs b/rb/sig/lib/selenium/webdriver/edge/service.rbs index 9723e6548efed..78aa3d90d4a10 100644 --- a/rb/sig/lib/selenium/webdriver/edge/service.rbs +++ b/rb/sig/lib/selenium/webdriver/edge/service.rbs @@ -2,6 +2,8 @@ module Selenium module WebDriver module Edge class Service < WebDriver::Service + PATH: String + @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/firefox/service.rbs b/rb/sig/lib/selenium/webdriver/firefox/service.rbs index 85073c264be3c..9ade9a90a1477 100644 --- a/rb/sig/lib/selenium/webdriver/firefox/service.rbs +++ b/rb/sig/lib/selenium/webdriver/firefox/service.rbs @@ -6,6 +6,7 @@ module Selenium EXECUTABLE: "geckodriver" + PATH: String SHUTDOWN_SUPPORTED: false end end diff --git a/rb/sig/lib/selenium/webdriver/ie/service.rbs b/rb/sig/lib/selenium/webdriver/ie/service.rbs index 94f9d492a292f..f1bb9f826c67e 100644 --- a/rb/sig/lib/selenium/webdriver/ie/service.rbs +++ b/rb/sig/lib/selenium/webdriver/ie/service.rbs @@ -6,6 +6,7 @@ module Selenium EXECUTABLE: String + PATH: String SHUTDOWN_SUPPORTED: bool end end From e0be3153c0fa679cad1bddc1dda46c74bc7f3643 Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 30 Aug 2024 15:15:50 +0200 Subject: [PATCH 03/10] Update RBS and tests --- rb/sig/lib/selenium/webdriver/safari/service.rbs | 1 + .../integration/selenium/webdriver/chrome/service_spec.rb | 6 ++++++ rb/spec/integration/selenium/webdriver/edge/service_spec.rb | 6 ++++++ .../integration/selenium/webdriver/firefox/service_spec.rb | 6 ++++++ .../selenium/webdriver/spec_support/test_environment.rb | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/rb/sig/lib/selenium/webdriver/safari/service.rbs b/rb/sig/lib/selenium/webdriver/safari/service.rbs index e75e317682014..92e8060a0c672 100644 --- a/rb/sig/lib/selenium/webdriver/safari/service.rbs +++ b/rb/sig/lib/selenium/webdriver/safari/service.rbs @@ -6,6 +6,7 @@ module Selenium EXECUTABLE: String + PATH: String SHUTDOWN_SUPPORTED: bool def initialize: (?path: untyped?, ?port: untyped?, ?log: untyped?, ?args: untyped?) -> void diff --git a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb index aed6ce922258d..f7dde440bd7a3 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb @@ -37,6 +37,12 @@ module Chrome it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + it 'uses the path from the environment' do + ENV['SE_CHROMEDRIVER'] = '/path/to/chromedriver' + + expect(service.executable_path).to eq '/path/to/chromedriver' + end end end # Chrome end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb index 39160cf62bcd0..74cbba4b4a06d 100644 --- a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb @@ -37,6 +37,12 @@ module Edge it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + it 'uses the path from the environment' do + ENV['SE_EDGEDRIVER'] = '/path/to/msedgedriver' + + expect(service.executable_path).to eq '/path/to/msedgedriver' + end end end # Edge end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb index 8cd66cc67619c..6da1f0d70cf54 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb @@ -37,6 +37,12 @@ module Firefox it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + it 'uses the path from the environment' do + ENV['SE_GECKODRIVER'] = '/path/to/geckodriver' + + expect(service.executable_path).to eq '/path/to/geckodriver' + end end end # Firefox end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb index 517a10ce1e909..4b503d4f72215 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -31,7 +31,7 @@ def initialize WebDriver.logger.ignore(:logger_info) SeleniumManager.bin_path = root.join('bazel-bin/rb/bin').to_s if File.exist?(root.join('bazel-bin/rb/bin')) - @driver = ENV.fetch('WD_SPEC_DRIVER', 'chrome').tr('-', '_').to_sym + @driver = ENV.fetch('WD_SPEC_DRIVER', 'firefox').tr('-', '_').to_sym @driver_instance = nil @remote_server = nil end From 154e35c908a5de21faec4aefc2ab619026622b1c Mon Sep 17 00:00:00 2001 From: aguspe Date: Mon, 2 Sep 2024 06:51:47 +0200 Subject: [PATCH 04/10] Remove firefox guard --- rb/lib/selenium/webdriver/common/service.rb | 12 ++++++++---- rb/lib/selenium/webdriver/safari/service.rb | 1 - .../webdriver/spec_support/test_environment.rb | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rb/lib/selenium/webdriver/common/service.rb b/rb/lib/selenium/webdriver/common/service.rb index 53d688e15b9ef..def91bfa37066 100644 --- a/rb/lib/selenium/webdriver/common/service.rb +++ b/rb/lib/selenium/webdriver/common/service.rb @@ -39,11 +39,13 @@ def firefox(**opts) def ie(**opts) IE::Service.new(**opts) end + alias internet_explorer ie def edge(**opts) Edge::Service.new(**opts) end + alias microsoftedge edge alias msedge edge @@ -88,16 +90,18 @@ def initialize(path: nil, port: nil, log: nil, args: nil) end def launch - @executable_path ||= begin - default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new - DriverFinder.new(default_options, self).driver_path - end + @executable_path ||= self.class::PATH || find_driver_path ServiceManager.new(self).tap(&:start) end def shutdown_supported self.class::SHUTDOWN_SUPPORTED end + + def find_driver_path + default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new + DriverFinder.new(default_options, self).driver_path + end end # Service end # WebDriver end # Selenium diff --git a/rb/lib/selenium/webdriver/safari/service.rb b/rb/lib/selenium/webdriver/safari/service.rb index 39534014b5c17..72a56bdf88561 100644 --- a/rb/lib/selenium/webdriver/safari/service.rb +++ b/rb/lib/selenium/webdriver/safari/service.rb @@ -24,7 +24,6 @@ class Service < WebDriver::Service DEFAULT_PORT = 7050 EXECUTABLE = 'safaridriver' SHUTDOWN_SUPPORTED = false - PATH = ENV.fetch('SE_SAFARIDRIVER', nil) def initialize(path: nil, port: nil, log: nil, args: nil) raise Error::WebDriverError, 'Safari Service does not support setting log output' if log diff --git a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb index 4b503d4f72215..517a10ce1e909 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -31,7 +31,7 @@ def initialize WebDriver.logger.ignore(:logger_info) SeleniumManager.bin_path = root.join('bazel-bin/rb/bin').to_s if File.exist?(root.join('bazel-bin/rb/bin')) - @driver = ENV.fetch('WD_SPEC_DRIVER', 'firefox').tr('-', '_').to_sym + @driver = ENV.fetch('WD_SPEC_DRIVER', 'chrome').tr('-', '_').to_sym @driver_instance = nil @remote_server = nil end From 09d6cb16c6d797083240ed77d17c2fea7faef6c3 Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 6 Sep 2024 11:03:32 +0200 Subject: [PATCH 05/10] Update environment to be working now --- rb/lib/selenium/webdriver/chrome/service.rb | 1 - rb/lib/selenium/webdriver/common/service.rb | 11 +++- rb/lib/selenium/webdriver/edge/service.rb | 1 - rb/lib/selenium/webdriver/firefox/service.rb | 1 - rb/lib/selenium/webdriver/ie/service.rb | 1 - .../lib/selenium/webdriver/chrome/service.rbs | 2 - .../lib/selenium/webdriver/common/service.rbs | 2 + .../lib/selenium/webdriver/edge/service.rbs | 1 - rb/sig/lib/selenium/webdriver/ie/service.rbs | 1 - .../lib/selenium/webdriver/safari/service.rbs | 1 - .../selenium/webdriver/chrome/service_spec.rb | 11 +++- .../selenium/webdriver/edge/service_spec.rb | 11 +++- .../webdriver/firefox/service_spec.rb | 11 +++- .../selenium/webdriver/ie/service_spec.rb | 56 +++++++++++++++++++ .../selenium/webdriver/safari/service_spec.rb | 56 +++++++++++++++++++ 15 files changed, 150 insertions(+), 17 deletions(-) create mode 100644 rb/spec/integration/selenium/webdriver/ie/service_spec.rb create mode 100644 rb/spec/integration/selenium/webdriver/safari/service_spec.rb diff --git a/rb/lib/selenium/webdriver/chrome/service.rb b/rb/lib/selenium/webdriver/chrome/service.rb index a927cb659adbe..82945bba8964a 100644 --- a/rb/lib/selenium/webdriver/chrome/service.rb +++ b/rb/lib/selenium/webdriver/chrome/service.rb @@ -24,7 +24,6 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'chromedriver' SHUTDOWN_SUPPORTED = true - PATH = ENV.fetch('SE_CHROMEDRIVER', nil) def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/common/service.rb b/rb/lib/selenium/webdriver/common/service.rb index def91bfa37066..44f3e3bce6ad4 100644 --- a/rb/lib/selenium/webdriver/common/service.rb +++ b/rb/lib/selenium/webdriver/common/service.rb @@ -71,7 +71,7 @@ def driver_path=(path) def initialize(path: nil, port: nil, log: nil, args: nil) port ||= self.class::DEFAULT_PORT args ||= [] - path ||= self.class::PATH + path ||= env_path @executable_path = path @host = Platform.localhost @@ -90,7 +90,7 @@ def initialize(path: nil, port: nil, log: nil, args: nil) end def launch - @executable_path ||= self.class::PATH || find_driver_path + @executable_path ||= env_path || find_driver_path ServiceManager.new(self).tap(&:start) end @@ -102,6 +102,13 @@ def find_driver_path default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new DriverFinder.new(default_options, self).driver_path end + + def env_path + class_name = self.class.name&.split('::')&.[](2)&.downcase + driver_name = class_name == 'firefox' ? 'gecko' : class_name + parsed_driver = "SE_#{driver_name&.upcase}DRIVER" + ENV.fetch(parsed_driver, nil) + end end # Service end # WebDriver end # Selenium diff --git a/rb/lib/selenium/webdriver/edge/service.rb b/rb/lib/selenium/webdriver/edge/service.rb index ef512aaeedaba..670a3064d8486 100644 --- a/rb/lib/selenium/webdriver/edge/service.rb +++ b/rb/lib/selenium/webdriver/edge/service.rb @@ -24,7 +24,6 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'msedgedriver' SHUTDOWN_SUPPORTED = true - PATH = ENV.fetch('SE_EDGEDRIVER', nil) def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/firefox/service.rb b/rb/lib/selenium/webdriver/firefox/service.rb index b2d3285080335..44f449f2a60d3 100644 --- a/rb/lib/selenium/webdriver/firefox/service.rb +++ b/rb/lib/selenium/webdriver/firefox/service.rb @@ -24,7 +24,6 @@ class Service < WebDriver::Service DEFAULT_PORT = 4444 EXECUTABLE = 'geckodriver' SHUTDOWN_SUPPORTED = false - PATH = ENV.fetch('SE_GECKODRIVER', nil) end # Service end # Firefox end # WebDriver diff --git a/rb/lib/selenium/webdriver/ie/service.rb b/rb/lib/selenium/webdriver/ie/service.rb index 5e8d963c4146b..079d1e0341113 100644 --- a/rb/lib/selenium/webdriver/ie/service.rb +++ b/rb/lib/selenium/webdriver/ie/service.rb @@ -24,7 +24,6 @@ class Service < WebDriver::Service DEFAULT_PORT = 5555 EXECUTABLE = 'IEDriverServer' SHUTDOWN_SUPPORTED = true - PATH = ENV.fetch('SE_IEDRIVER', nil) end # Server end # IE end # WebDriver diff --git a/rb/sig/lib/selenium/webdriver/chrome/service.rbs b/rb/sig/lib/selenium/webdriver/chrome/service.rbs index 579323dc508b2..a94d9c8d4900c 100644 --- a/rb/sig/lib/selenium/webdriver/chrome/service.rbs +++ b/rb/sig/lib/selenium/webdriver/chrome/service.rbs @@ -2,8 +2,6 @@ module Selenium module WebDriver module Chrome class Service < WebDriver::Service - PATH: String - @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/common/service.rbs b/rb/sig/lib/selenium/webdriver/common/service.rbs index a6abee02e79d2..e07af9ac3e1ce 100644 --- a/rb/sig/lib/selenium/webdriver/common/service.rbs +++ b/rb/sig/lib/selenium/webdriver/common/service.rbs @@ -47,6 +47,8 @@ module Selenium attr_accessor args: untyped + def env_path: -> String + alias extra_args args def initialize: (?path: untyped?, ?port: untyped?, ?log: untyped?, ?args: untyped?) -> void diff --git a/rb/sig/lib/selenium/webdriver/edge/service.rbs b/rb/sig/lib/selenium/webdriver/edge/service.rbs index 78aa3d90d4a10..47a94aaf99f3d 100644 --- a/rb/sig/lib/selenium/webdriver/edge/service.rbs +++ b/rb/sig/lib/selenium/webdriver/edge/service.rbs @@ -2,7 +2,6 @@ module Selenium module WebDriver module Edge class Service < WebDriver::Service - PATH: String @log: untyped diff --git a/rb/sig/lib/selenium/webdriver/ie/service.rbs b/rb/sig/lib/selenium/webdriver/ie/service.rbs index f1bb9f826c67e..94f9d492a292f 100644 --- a/rb/sig/lib/selenium/webdriver/ie/service.rbs +++ b/rb/sig/lib/selenium/webdriver/ie/service.rbs @@ -6,7 +6,6 @@ module Selenium EXECUTABLE: String - PATH: String SHUTDOWN_SUPPORTED: bool end end diff --git a/rb/sig/lib/selenium/webdriver/safari/service.rbs b/rb/sig/lib/selenium/webdriver/safari/service.rbs index 92e8060a0c672..e75e317682014 100644 --- a/rb/sig/lib/selenium/webdriver/safari/service.rbs +++ b/rb/sig/lib/selenium/webdriver/safari/service.rbs @@ -6,7 +6,6 @@ module Selenium EXECUTABLE: String - PATH: String SHUTDOWN_SUPPORTED: bool def initialize: (?path: untyped?, ?port: untyped?, ?log: untyped?, ?args: untyped?) -> void diff --git a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb index f7dde440bd7a3..0ac34b0004e87 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb @@ -39,9 +39,16 @@ module Chrome end it 'uses the path from the environment' do - ENV['SE_CHROMEDRIVER'] = '/path/to/chromedriver' + ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - expect(service.executable_path).to eq '/path/to/chromedriver' + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_CHROMEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) end end end # Chrome diff --git a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb index 74cbba4b4a06d..3ab217958ed2d 100644 --- a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb @@ -39,9 +39,16 @@ module Edge end it 'uses the path from the environment' do - ENV['SE_EDGEDRIVER'] = '/path/to/msedgedriver' + ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - expect(service.executable_path).to eq '/path/to/msedgedriver' + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_EDGEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) end end end # Edge diff --git a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb index 6da1f0d70cf54..45bec5f9e2650 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb @@ -39,9 +39,16 @@ module Firefox end it 'uses the path from the environment' do - ENV['SE_GECKODRIVER'] = '/path/to/geckodriver' + ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - expect(service.executable_path).to eq '/path/to/geckodriver' + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_GECKODRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) end end end # Firefox diff --git a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb new file mode 100644 index 0000000000000..ed97ba1138dac --- /dev/null +++ b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require_relative '../spec_helper' + +module Selenium + module WebDriver + module IE + describe Service, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :ie}] do + let(:service) { described_class.new } + let(:service_manager) { service.launch } + + after { service_manager.stop } + + it 'auto uses iedriver' do + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + + it 'can be started outside driver' do + expect(service_manager.uri).to be_a(URI) + end + + it 'uses the path from the environment' do + ENV['SE_IEIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_IEIDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end + end # IE + end # WebDriver +end # Selenium diff --git a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb new file mode 100644 index 0000000000000..2f09fe16299c1 --- /dev/null +++ b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +require_relative '../spec_helper' + +module Selenium + module WebDriver + module Safari + describe Service, exclusive: [{bidi: false, reason: 'Not yet implemented with BiDi'}, {browser: :safari}] do + let(:service) { described_class.new } + let(:service_manager) { service.launch } + + after { service_manager.stop } + + it 'auto uses safaridriver' do + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + + it 'can be started outside driver' do + expect(service_manager.uri).to be_a(URI) + end + + it 'uses the path from the environment' do + ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_SAFARIDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end + end # Safari + end # WebDriver +end # Selenium From b0f0277bbcdf4c743a85b7cce1bd1e4f1866dcbc Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 6 Sep 2024 11:04:26 +0200 Subject: [PATCH 06/10] Remove extra spaces --- rb/lib/selenium/webdriver/common/service.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/rb/lib/selenium/webdriver/common/service.rb b/rb/lib/selenium/webdriver/common/service.rb index 44f3e3bce6ad4..5dd8e837ca640 100644 --- a/rb/lib/selenium/webdriver/common/service.rb +++ b/rb/lib/selenium/webdriver/common/service.rb @@ -39,13 +39,11 @@ def firefox(**opts) def ie(**opts) IE::Service.new(**opts) end - alias internet_explorer ie def edge(**opts) Edge::Service.new(**opts) end - alias microsoftedge edge alias msedge edge From d57095b0a7b6fb295921b59fc99168498bdbb0b5 Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 6 Sep 2024 11:05:55 +0200 Subject: [PATCH 07/10] update rbs --- rb/sig/lib/selenium/webdriver/edge/service.rbs | 1 - rb/sig/lib/selenium/webdriver/firefox/service.rbs | 1 - 2 files changed, 2 deletions(-) diff --git a/rb/sig/lib/selenium/webdriver/edge/service.rbs b/rb/sig/lib/selenium/webdriver/edge/service.rbs index 47a94aaf99f3d..9723e6548efed 100644 --- a/rb/sig/lib/selenium/webdriver/edge/service.rbs +++ b/rb/sig/lib/selenium/webdriver/edge/service.rbs @@ -2,7 +2,6 @@ module Selenium module WebDriver module Edge class Service < WebDriver::Service - @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/firefox/service.rbs b/rb/sig/lib/selenium/webdriver/firefox/service.rbs index 9ade9a90a1477..85073c264be3c 100644 --- a/rb/sig/lib/selenium/webdriver/firefox/service.rbs +++ b/rb/sig/lib/selenium/webdriver/firefox/service.rbs @@ -6,7 +6,6 @@ module Selenium EXECUTABLE: "geckodriver" - PATH: String SHUTDOWN_SUPPORTED: false end end From d20738416f23dc28545db4778ccdcb61892f14f8 Mon Sep 17 00:00:00 2001 From: aguspe Date: Fri, 13 Sep 2024 22:49:49 +0200 Subject: [PATCH 08/10] Move tests from integration to unit tests --- .../selenium/webdriver/chrome/service_spec.rb | 13 ------------- .../selenium/webdriver/edge/service_spec.rb | 13 ------------- .../selenium/webdriver/firefox/service_spec.rb | 13 ------------- .../selenium/webdriver/ie/service_spec.rb | 13 ------------- .../selenium/webdriver/safari/service_spec.rb | 13 ------------- .../selenium/webdriver/chrome/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/edge/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/firefox/service_spec.rb | 17 +++++++++++++++++ .../unit/selenium/webdriver/ie/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/safari/service_spec.rb | 17 +++++++++++++++++ 10 files changed, 85 insertions(+), 65 deletions(-) diff --git a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb index 0ac34b0004e87..aed6ce922258d 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb @@ -37,19 +37,6 @@ module Chrome it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - it 'uses the path from the environment' do - ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_CHROMEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end end end # Chrome end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb index 3ab217958ed2d..39160cf62bcd0 100644 --- a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb @@ -37,19 +37,6 @@ module Edge it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - it 'uses the path from the environment' do - ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_EDGEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end end end # Edge end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb index 45bec5f9e2650..8cd66cc67619c 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb @@ -37,19 +37,6 @@ module Firefox it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - it 'uses the path from the environment' do - ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_GECKODRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end end end # Firefox end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb index ed97ba1138dac..bee1f25908de6 100644 --- a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb @@ -37,19 +37,6 @@ module IE it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - it 'uses the path from the environment' do - ENV['SE_IEIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_IEIDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end end end # IE end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb index 2f09fe16299c1..c040a637828da 100644 --- a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb @@ -37,19 +37,6 @@ module Safari it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - it 'uses the path from the environment' do - ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_SAFARIDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end end end # Safari end # WebDriver diff --git a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb index c2f2ebf241841..242862c4b5b30 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb @@ -119,6 +119,23 @@ module Chrome driver.new(service: service) expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + before { ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_CHROMEDRIVER') } + + it 'uses the path from the environment' do + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_CHROMEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end end end end # Chrome diff --git a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb index 8f398ca999693..250219593c673 100644 --- a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb @@ -129,6 +129,23 @@ module Edge expect(service.log).to be_nil expect(service.args).to eq ['--log-path=/path/to/log.txt'] end + + context 'with a path env variable' do + before { ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_EDGEDRIVER') } + + it 'uses the path from the environment' do + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_EDGEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end end end end # Edge diff --git a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb index 60268fcd02eb4..650c59afe7bc3 100644 --- a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb @@ -117,6 +117,23 @@ module Firefox expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + before { ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_GECKODRIVER') } + + it 'uses the path from the environment' do + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_GECKODRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end end end end # Firefox diff --git a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb index 34f102ca94f75..c2997ed69e5a0 100644 --- a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb @@ -119,6 +119,23 @@ module IE expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + before { ENV['SE_IEIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_IEIDRIVER') } + + it 'uses the path from the environment' do + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_IEIDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end end end end # IE diff --git a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb index 9ae84dba3be74..5a396eced5045 100644 --- a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb @@ -114,6 +114,23 @@ module Safari expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + before { ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_SAFARIDRIVER') } + + it 'uses the path from the environment' do + expect(service_manager.uri).to be_a(URI) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_SAFARIDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service_manager.uri).to be_a(URI) + end + end end end end # Safari From 18a140a1d252ec700e511ff84259d196ef64102f Mon Sep 17 00:00:00 2001 From: aguspe Date: Sat, 14 Sep 2024 10:44:31 +0200 Subject: [PATCH 09/10] Update specs and add service environment variable --- rb/lib/selenium/webdriver/chrome/service.rb | 1 + rb/lib/selenium/webdriver/common/service.rb | 5 +---- rb/lib/selenium/webdriver/edge/service.rb | 1 + rb/lib/selenium/webdriver/firefox/service.rb | 1 + rb/lib/selenium/webdriver/ie/service.rb | 1 + rb/lib/selenium/webdriver/safari/service.rb | 1 + .../lib/selenium/webdriver/chrome/service.rbs | 2 ++ rb/sig/lib/selenium/webdriver/edge/service.rbs | 2 ++ .../lib/selenium/webdriver/firefox/service.rbs | 1 + rb/sig/lib/selenium/webdriver/ie/service.rbs | 1 + .../lib/selenium/webdriver/safari/service.rbs | 1 + .../selenium/webdriver/chrome/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/edge/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/firefox/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/ie/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/safari/service_spec.rb | 17 +++++++++++++++++ .../selenium/webdriver/chrome/service_spec.rb | 17 ----------------- .../selenium/webdriver/edge/service_spec.rb | 17 ----------------- .../selenium/webdriver/firefox/service_spec.rb | 17 ----------------- .../unit/selenium/webdriver/ie/service_spec.rb | 17 ----------------- .../selenium/webdriver/safari/service_spec.rb | 17 ----------------- 21 files changed, 98 insertions(+), 89 deletions(-) diff --git a/rb/lib/selenium/webdriver/chrome/service.rb b/rb/lib/selenium/webdriver/chrome/service.rb index 82945bba8964a..834c80d8ea461 100644 --- a/rb/lib/selenium/webdriver/chrome/service.rb +++ b/rb/lib/selenium/webdriver/chrome/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'chromedriver' SHUTDOWN_SUPPORTED = true + DRIVER_PATH_ENV_KEY = 'SE_CHROMEDRIVER' def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/common/service.rb b/rb/lib/selenium/webdriver/common/service.rb index 5dd8e837ca640..b0f274959ebeb 100644 --- a/rb/lib/selenium/webdriver/common/service.rb +++ b/rb/lib/selenium/webdriver/common/service.rb @@ -102,10 +102,7 @@ def find_driver_path end def env_path - class_name = self.class.name&.split('::')&.[](2)&.downcase - driver_name = class_name == 'firefox' ? 'gecko' : class_name - parsed_driver = "SE_#{driver_name&.upcase}DRIVER" - ENV.fetch(parsed_driver, nil) + ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil) end end # Service end # WebDriver diff --git a/rb/lib/selenium/webdriver/edge/service.rb b/rb/lib/selenium/webdriver/edge/service.rb index 670a3064d8486..3d99635c59f62 100644 --- a/rb/lib/selenium/webdriver/edge/service.rb +++ b/rb/lib/selenium/webdriver/edge/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 9515 EXECUTABLE = 'msedgedriver' SHUTDOWN_SUPPORTED = true + DRIVER_PATH_ENV_KEY = 'SE_EDGEDRIVER' def log return @log unless @log.is_a? String diff --git a/rb/lib/selenium/webdriver/firefox/service.rb b/rb/lib/selenium/webdriver/firefox/service.rb index 44f449f2a60d3..ce1526d1ef718 100644 --- a/rb/lib/selenium/webdriver/firefox/service.rb +++ b/rb/lib/selenium/webdriver/firefox/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 4444 EXECUTABLE = 'geckodriver' SHUTDOWN_SUPPORTED = false + DRIVER_PATH_ENV_KEY = 'SE_GECKODRIVER' end # Service end # Firefox end # WebDriver diff --git a/rb/lib/selenium/webdriver/ie/service.rb b/rb/lib/selenium/webdriver/ie/service.rb index 079d1e0341113..9c3b8967e74a4 100644 --- a/rb/lib/selenium/webdriver/ie/service.rb +++ b/rb/lib/selenium/webdriver/ie/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 5555 EXECUTABLE = 'IEDriverServer' SHUTDOWN_SUPPORTED = true + DRIVER_PATH_ENV_KEY = 'SE_IEDRIVER' end # Server end # IE end # WebDriver diff --git a/rb/lib/selenium/webdriver/safari/service.rb b/rb/lib/selenium/webdriver/safari/service.rb index 72a56bdf88561..8b4182aab47be 100644 --- a/rb/lib/selenium/webdriver/safari/service.rb +++ b/rb/lib/selenium/webdriver/safari/service.rb @@ -24,6 +24,7 @@ class Service < WebDriver::Service DEFAULT_PORT = 7050 EXECUTABLE = 'safaridriver' SHUTDOWN_SUPPORTED = false + DRIVER_PATH_ENV_KEY = 'SE_SAFARIDRIVER' def initialize(path: nil, port: nil, log: nil, args: nil) raise Error::WebDriverError, 'Safari Service does not support setting log output' if log diff --git a/rb/sig/lib/selenium/webdriver/chrome/service.rbs b/rb/sig/lib/selenium/webdriver/chrome/service.rbs index a94d9c8d4900c..a8fa6e98d4bc0 100644 --- a/rb/sig/lib/selenium/webdriver/chrome/service.rbs +++ b/rb/sig/lib/selenium/webdriver/chrome/service.rbs @@ -2,6 +2,8 @@ module Selenium module WebDriver module Chrome class Service < WebDriver::Service + DRIVER_PATH_ENV_KEY: String + @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/edge/service.rbs b/rb/sig/lib/selenium/webdriver/edge/service.rbs index 9723e6548efed..85752e9c03fba 100644 --- a/rb/sig/lib/selenium/webdriver/edge/service.rbs +++ b/rb/sig/lib/selenium/webdriver/edge/service.rbs @@ -2,6 +2,8 @@ module Selenium module WebDriver module Edge class Service < WebDriver::Service + DRIVER_PATH_ENV_KEY: String + @log: untyped DEFAULT_PORT: Integer diff --git a/rb/sig/lib/selenium/webdriver/firefox/service.rbs b/rb/sig/lib/selenium/webdriver/firefox/service.rbs index 85073c264be3c..64d996b973a04 100644 --- a/rb/sig/lib/selenium/webdriver/firefox/service.rbs +++ b/rb/sig/lib/selenium/webdriver/firefox/service.rbs @@ -4,6 +4,7 @@ module Selenium class Service < WebDriver::Service DEFAULT_PORT: 4444 + DRIVER_PATH_ENV_KEY: String EXECUTABLE: "geckodriver" SHUTDOWN_SUPPORTED: false diff --git a/rb/sig/lib/selenium/webdriver/ie/service.rbs b/rb/sig/lib/selenium/webdriver/ie/service.rbs index 94f9d492a292f..e39fc16a850fd 100644 --- a/rb/sig/lib/selenium/webdriver/ie/service.rbs +++ b/rb/sig/lib/selenium/webdriver/ie/service.rbs @@ -4,6 +4,7 @@ module Selenium class Service < WebDriver::Service DEFAULT_PORT: Integer + DRIVER_PATH_ENV_KEY: String EXECUTABLE: String SHUTDOWN_SUPPORTED: bool diff --git a/rb/sig/lib/selenium/webdriver/safari/service.rbs b/rb/sig/lib/selenium/webdriver/safari/service.rbs index e75e317682014..171f0addbef93 100644 --- a/rb/sig/lib/selenium/webdriver/safari/service.rbs +++ b/rb/sig/lib/selenium/webdriver/safari/service.rbs @@ -4,6 +4,7 @@ module Selenium class Service < WebDriver::Service DEFAULT_PORT: Integer + DRIVER_PATH_ENV_KEY: String EXECUTABLE: String SHUTDOWN_SUPPORTED: bool diff --git a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb index aed6ce922258d..19faa14515fba 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb @@ -37,6 +37,23 @@ module Chrome it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + context 'with a path env variable' do + before { ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_CHROMEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/chromedriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_CHROMEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service.executable_path).to match(/chromedriver/) + end + end end end # Chrome end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb index 39160cf62bcd0..f39daafc59295 100644 --- a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb @@ -37,6 +37,23 @@ module Edge it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + context 'with a path env variable' do + before { ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_EDGEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/edgedriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_EDGEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service.executable_path).to match(/edgedriver/) + end + end end end # Edge end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb index 8cd66cc67619c..f48b08761ce83 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb @@ -37,6 +37,23 @@ module Firefox it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + context 'with a path env variable' do + before { ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_GECKODRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/geckodriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_GECKODRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service.executable_path).to match(/geckodriver/) + end + end end end # Firefox end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb index bee1f25908de6..21758761afdc8 100644 --- a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb @@ -37,6 +37,23 @@ module IE it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + context 'with a path env variable' do + before { ENV['SE_IEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_IEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/iedriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_IEDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service.executable_path).to match(/iedriver/) + end + end end end # IE end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb index c040a637828da..781f952fcbb71 100644 --- a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb @@ -37,6 +37,23 @@ module Safari it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end + + context 'with a path env variable' do + before { ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } + + after { ENV.delete('SE_SAFARIDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/safaridriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_SAFARIDRIVER'] = '/foo/bar' + service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path + + expect(service.executable_path).to match(/safaridriver/) + end + end end end # Safari end # WebDriver diff --git a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb index 242862c4b5b30..c2f2ebf241841 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb @@ -119,23 +119,6 @@ module Chrome driver.new(service: service) expect(described_class).not_to have_received(:new) end - - context 'with a path env variable' do - before { ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_CHROMEDRIVER') } - - it 'uses the path from the environment' do - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_CHROMEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - end end end end # Chrome diff --git a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb index 250219593c673..8f398ca999693 100644 --- a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb @@ -129,23 +129,6 @@ module Edge expect(service.log).to be_nil expect(service.args).to eq ['--log-path=/path/to/log.txt'] end - - context 'with a path env variable' do - before { ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_EDGEDRIVER') } - - it 'uses the path from the environment' do - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_EDGEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - end end end end # Edge diff --git a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb index 650c59afe7bc3..60268fcd02eb4 100644 --- a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb @@ -117,23 +117,6 @@ module Firefox expect(described_class).not_to have_received(:new) end - - context 'with a path env variable' do - before { ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_GECKODRIVER') } - - it 'uses the path from the environment' do - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_GECKODRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - end end end end # Firefox diff --git a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb index c2997ed69e5a0..34f102ca94f75 100644 --- a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb @@ -119,23 +119,6 @@ module IE expect(described_class).not_to have_received(:new) end - - context 'with a path env variable' do - before { ENV['SE_IEIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_IEIDRIVER') } - - it 'uses the path from the environment' do - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_IEIDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - end end end end # IE diff --git a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb index 5a396eced5045..9ae84dba3be74 100644 --- a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb @@ -114,23 +114,6 @@ module Safari expect(described_class).not_to have_received(:new) end - - context 'with a path env variable' do - before { ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_SAFARIDRIVER') } - - it 'uses the path from the environment' do - expect(service_manager.uri).to be_a(URI) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_SAFARIDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service_manager.uri).to be_a(URI) - end - end end end end # Safari From 9975b39c3197731d41a705319d8cffef1b8d190c Mon Sep 17 00:00:00 2001 From: aguspe Date: Sun, 15 Sep 2024 19:06:02 +0200 Subject: [PATCH 10/10] Move the integration tests to unit tests --- .../selenium/webdriver/chrome/service_spec.rb | 17 -------------- .../selenium/webdriver/edge/service_spec.rb | 17 -------------- .../webdriver/firefox/service_spec.rb | 17 -------------- .../selenium/webdriver/ie/service_spec.rb | 17 -------------- .../selenium/webdriver/safari/service_spec.rb | 17 -------------- .../selenium/webdriver/chrome/service_spec.rb | 22 +++++++++++++++++++ .../selenium/webdriver/edge/service_spec.rb | 22 +++++++++++++++++++ .../webdriver/firefox/service_spec.rb | 22 +++++++++++++++++++ .../selenium/webdriver/ie/service_spec.rb | 22 +++++++++++++++++++ .../selenium/webdriver/safari/service_spec.rb | 22 +++++++++++++++++++ 10 files changed, 110 insertions(+), 85 deletions(-) diff --git a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb index 19faa14515fba..aed6ce922258d 100644 --- a/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/chrome/service_spec.rb @@ -37,23 +37,6 @@ module Chrome it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - context 'with a path env variable' do - before { ENV['SE_CHROMEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_CHROMEDRIVER') } - - it 'uses the path from the environment' do - expect(service.executable_path).to match(/chromedriver/) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_CHROMEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service.executable_path).to match(/chromedriver/) - end - end end end # Chrome end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb index f39daafc59295..39160cf62bcd0 100644 --- a/rb/spec/integration/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/edge/service_spec.rb @@ -37,23 +37,6 @@ module Edge it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - context 'with a path env variable' do - before { ENV['SE_EDGEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_EDGEDRIVER') } - - it 'uses the path from the environment' do - expect(service.executable_path).to match(/edgedriver/) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_EDGEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service.executable_path).to match(/edgedriver/) - end - end end end # Edge end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb index f48b08761ce83..8cd66cc67619c 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/service_spec.rb @@ -37,23 +37,6 @@ module Firefox it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - context 'with a path env variable' do - before { ENV['SE_GECKODRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_GECKODRIVER') } - - it 'uses the path from the environment' do - expect(service.executable_path).to match(/geckodriver/) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_GECKODRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service.executable_path).to match(/geckodriver/) - end - end end end # Firefox end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb index 21758761afdc8..bee1f25908de6 100644 --- a/rb/spec/integration/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/ie/service_spec.rb @@ -37,23 +37,6 @@ module IE it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - context 'with a path env variable' do - before { ENV['SE_IEDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_IEDRIVER') } - - it 'uses the path from the environment' do - expect(service.executable_path).to match(/iedriver/) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_IEDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service.executable_path).to match(/iedriver/) - end - end end end # IE end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb index 781f952fcbb71..c040a637828da 100644 --- a/rb/spec/integration/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/integration/selenium/webdriver/safari/service_spec.rb @@ -37,23 +37,6 @@ module Safari it 'can be started outside driver' do expect(service_manager.uri).to be_a(URI) end - - context 'with a path env variable' do - before { ENV['SE_SAFARIDRIVER'] = DriverFinder.new(Options.new, described_class.new).driver_path } - - after { ENV.delete('SE_SAFARIDRIVER') } - - it 'uses the path from the environment' do - expect(service.executable_path).to match(/safaridriver/) - end - - it 'updates the path after setting the environment variable' do - ENV['SE_SAFARIDRIVER'] = '/foo/bar' - service.executable_path = DriverFinder.new(Options.new, described_class.new).driver_path - - expect(service.executable_path).to match(/safaridriver/) - end - end end end # Safari end # WebDriver diff --git a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb index c2f2ebf241841..cbbe6f9ed7ed5 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/service_spec.rb @@ -119,6 +119,28 @@ module Chrome driver.new(service: service) expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + let(:service) { described_class.new } + let(:service_path) { "/path/to/#{Service::EXECUTABLE}" } + + before do + ENV['SE_CHROMEDRIVER'] = service_path + end + + after { ENV.delete('SE_CHROMEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/chromedriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_CHROMEDRIVER'] = '/foo/bar' + service.executable_path = service_path + + expect(service.executable_path).to match(/chromedriver/) + end + end end end end # Chrome diff --git a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb index 8f398ca999693..048f2170df300 100644 --- a/rb/spec/unit/selenium/webdriver/edge/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/edge/service_spec.rb @@ -129,6 +129,28 @@ module Edge expect(service.log).to be_nil expect(service.args).to eq ['--log-path=/path/to/log.txt'] end + + context 'with a path env variable' do + let(:service) { described_class.new } + let(:service_path) { "/path/to/#{Service::EXECUTABLE}" } + + before do + ENV['SE_EDGEDRIVER'] = service_path + end + + after { ENV.delete('SE_EDGEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/edgedriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_EDGEDRIVER'] = '/foo/bar' + service.executable_path = service_path + + expect(service.executable_path).to match(/edgedriver/) + end + end end end end # Edge diff --git a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb index 60268fcd02eb4..811894e74f4e3 100644 --- a/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/firefox/service_spec.rb @@ -117,6 +117,28 @@ module Firefox expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + let(:service) { described_class.new } + let(:service_path) { "/path/to/#{Service::EXECUTABLE}" } + + before do + ENV['SE_GECKODRIVER'] = service_path + end + + after { ENV.delete('SE_GECKODRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/geckodriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_GECKODRIVER'] = '/foo/bar' + service.executable_path = service_path + + expect(service.executable_path).to match(/geckodriver/) + end + end end end end # Firefox diff --git a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb index 34f102ca94f75..3c6ecd4edefb6 100644 --- a/rb/spec/unit/selenium/webdriver/ie/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/ie/service_spec.rb @@ -119,6 +119,28 @@ module IE expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + let(:service) { described_class.new } + let(:service_path) { "/path/to/#{Service::EXECUTABLE}" } + + before do + ENV['SE_IEDRIVER'] = service_path + end + + after { ENV.delete('SE_IEDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/IEDriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_IEDRIVER'] = '/foo/bar' + service.executable_path = service_path + + expect(service.executable_path).to match(/IEDriver/) + end + end end end end # IE diff --git a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb index 9ae84dba3be74..b24ff0cb45688 100644 --- a/rb/spec/unit/selenium/webdriver/safari/service_spec.rb +++ b/rb/spec/unit/selenium/webdriver/safari/service_spec.rb @@ -114,6 +114,28 @@ module Safari expect(described_class).not_to have_received(:new) end + + context 'with a path env variable' do + let(:service) { described_class.new } + let(:service_path) { "/path/to/#{Service::EXECUTABLE}" } + + before do + ENV['SE_SAFARIDRIVER'] = service_path + end + + after { ENV.delete('SE_SAFARIDRIVER') } + + it 'uses the path from the environment' do + expect(service.executable_path).to match(/safaridriver/) + end + + it 'updates the path after setting the environment variable' do + ENV['SE_SAFARIDRIVER'] = '/foo/bar' + service.executable_path = service_path + + expect(service.executable_path).to match(/safaridriver/) + end + end end end end # Safari