Skip to content

Commit f04c59b

Browse files
authored
Merge pull request rails#51664 from Earlopain/selenium-webdriver-deprecation
Resolve deprecation warning in latest `selenium-webdriver`
2 parents 49c43a4 + 6233309 commit f04c59b

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ gem "rake", ">= 13"
1111
gem "sprockets-rails", ">= 2.0.0"
1212
gem "propshaft", ">= 0.1.7"
1313
gem "capybara", ">= 3.39"
14-
gem "selenium-webdriver", ">= 4.11.0", "!= 4.20.0"
14+
gem "selenium-webdriver", ">= 4.20.0"
1515

1616
gem "rack-cache", "~> 1.2"
1717
gem "stimulus-rails"

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ GEM
491491
google-protobuf (~> 3.25)
492492
sass-embedded (1.69.6-x86_64-linux-gnu)
493493
google-protobuf (~> 3.25)
494-
selenium-webdriver (4.19.0)
494+
selenium-webdriver (4.20.1)
495495
base64 (~> 0.2)
496496
rexml (~> 3.2, >= 3.2.5)
497497
rubyzip (>= 1.2.2, < 3.0)
@@ -654,7 +654,7 @@ DEPENDENCIES
654654
rubocop-rails-omakase
655655
rubyzip (~> 2.0)
656656
sdoc!
657-
selenium-webdriver (>= 4.11.0, != 4.20.0)
657+
selenium-webdriver (>= 4.20.0)
658658
sidekiq
659659
sneakers
660660
sprockets-rails (>= 2.0.0)

actionpack/lib/action_dispatch/system_testing/browser.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ def set_headless_firefox_browser_options
7272
end
7373

7474
def resolve_driver_path(namespace)
75-
namespace::Service.driver_path = ::Selenium::WebDriver::DriverFinder.path(options, namespace::Service)
75+
# The path method has been deprecated in 4.20.0
76+
if Gem::Version.new(::Selenium::WebDriver::VERSION) >= Gem::Version.new("4.20.0")
77+
namespace::Service.driver_path = ::Selenium::WebDriver::DriverFinder.new(options, namespace::Service.new).driver_path
78+
else
79+
namespace::Service.driver_path = ::Selenium::WebDriver::DriverFinder.path(options, namespace::Service)
80+
end
7681
end
7782
end
7883
end

actionpack/test/dispatch/system_testing/driver_test.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ class DriverTest < ActiveSupport::TestCase
152152
original_driver_path = ::Selenium::WebDriver::Chrome::Service.driver_path
153153
::Selenium::WebDriver::Chrome::Service.driver_path = nil
154154

155-
# Our stub must return a path to a real executable, otherwise an internal Selenium assertion will fail.
155+
# Our stub must return paths to a real executables, otherwise an internal Selenium assertion will fail.
156+
# Note: SeleniumManager is private api
156157
found_executable = RbConfig.ruby
157-
::Selenium::WebDriver::SeleniumManager.stub(:driver_path, found_executable) do
158+
::Selenium::WebDriver::SeleniumManager.stub(:binary_paths, { "driver_path" => found_executable, "browser_path" => found_executable }) do
158159
ActionDispatch::SystemTesting::Driver.new(:selenium, screen_size: [1400, 1400], using: :chrome)
159160
end
160161

0 commit comments

Comments
 (0)