Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/system_testing/browser.rb
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions actionpack/test/dispatch/system_testing/driver_test.rb
Expand Up @@ -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)
Expand All @@ -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)
Expand Down