Fix: Do not execute selenium driver_path if it is a string.

This commit is contained in:
Yoann Lecuyer 2023-07-22 18:09:11 +02:00
parent 034cae80a9
commit bd8a6778a0
2 changed files with 18 additions and 2 deletions

@ -33,9 +33,9 @@ def configure
def preload
case type
when :chrome
::Selenium::WebDriver::Chrome::Service.driver_path&.call
::Selenium::WebDriver::Chrome::Service.driver_path.try(:call)
when :firefox
::Selenium::WebDriver::Firefox::Service.driver_path&.call
::Selenium::WebDriver::Firefox::Service.driver_path.try(:call)
end
end

@ -28,6 +28,14 @@ class DriverTest < ActiveSupport::TestCase
assert_equal ({ url: "http://example.com/wd/hub" }), driver.instance_variable_get(:@options)
end
test "initializing the driver with a headless chrome and custom path" do
original_driver_path = ::Selenium::WebDriver::Chrome::Service.driver_path
::Selenium::WebDriver::Chrome::Service.driver_path = "bin/test"
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_chrome, screen_size: [1400, 1400])
ensure
::Selenium::WebDriver::Chrome::Service.driver_path = original_driver_path
end
test "initializing the driver with a headless firefox" do
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_firefox, screen_size: [1400, 1400], options: { url: "http://example.com/wd/hub" })
assert_equal :selenium, driver.instance_variable_get(:@driver_type)
@ -37,6 +45,14 @@ class DriverTest < ActiveSupport::TestCase
assert_equal ({ url: "http://example.com/wd/hub" }), driver.instance_variable_get(:@options)
end
test "initializing the driver with a headless firefox and custom path" do
original_driver_path = ::Selenium::WebDriver::Firefox::Service.driver_path
::Selenium::WebDriver::Firefox::Service.driver_path = "bin/test"
ActionDispatch::SystemTesting::Driver.new(:selenium, using: :headless_firefox, screen_size: [1400, 1400])
ensure
::Selenium::WebDriver::Firefox::Service.driver_path = original_driver_path
end
test "initializing the driver with a cuprite" do
driver = ActionDispatch::SystemTesting::Driver.new(:cuprite, screen_size: [1400, 1400], options: { js_errors: false })
assert_equal :cuprite, driver.instance_variable_get(:@driver_type)