Description
Overview
In Arch Linux I was trying to use selenium-webdriver to test content on a page but I got an error instead. This error also happens on a freshly created Rails project.
Stacktrace
Error:
WelcomesTest#test_visiting_the_index:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 151
Current browser version is 150.0.7871.186 with binary path /opt/google/chrome/chrome
test/system/welcomes_test.rb:5:in 'block in <class:WelcomesTest>'
Error:
WelcomesTest#test_visiting_the_index:
Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 151
Current browser version is 150.0.7871.186 with binary path /opt/google/chrome/chrome
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:63:in 'Selenium::WebDriver::Remote::Response#add_cause'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:41:in 'Selenium::WebDriver::Remote::Response#error'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:52:in 'Selenium::WebDriver::Remote::Response#assert_ok'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:34:in 'Selenium::WebDriver::Remote::Response#initialize'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/common.rb:148:in 'Selenium::WebDriver::Remote::Http::Common#create_response'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/default.rb:122:in 'Selenium::WebDriver::Remote::Http::Default#request'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/common.rb:87:in 'Selenium::WebDriver::Remote::Http::Common#call'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/bridge.rb:631:in 'Selenium::WebDriver::Remote::Bridge#execute'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/bridge.rb:69:in 'Selenium::WebDriver::Remote::Bridge#create_session'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:325:in 'block in Selenium::WebDriver::Driver#create_bridge'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:324:in 'Kernel#tap'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:324:in 'Selenium::WebDriver::Driver#create_bridge'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:73:in 'Selenium::WebDriver::Driver#initialize'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/chrome/driver.rb:35:in 'block in Selenium::WebDriver::Chrome::Driver#initialize'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/local_driver.rb:32:in 'Selenium::WebDriver::LocalDriver#initialize_local_driver'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/chrome/driver.rb:34:in 'Selenium::WebDriver::Chrome::Driver#initialize'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:47:in 'Selenium::WebDriver::Driver.for'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver.rb:88:in 'Selenium::WebDriver.for'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/selenium/driver.rb:75:in 'Capybara::Selenium::Driver#browser'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:57:in 'block in ActionDispatch::SystemTesting::Driver#register_selenium'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:56:in 'Kernel#tap'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:56:in 'ActionDispatch::SystemTesting::Driver#register_selenium'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:43:in 'block in ActionDispatch::SystemTesting::Driver#register'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/session.rb:106:in 'Capybara::Session#driver'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/session.rb:92:in 'Capybara::Session#initialize'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara.rb:422:in 'block in Capybara.session_pool'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara.rb:317:in 'Capybara.current_session'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/dsl.rb:46:in 'Capybara::DSL#page'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:116:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#save_image'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:46:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#take_screenshot'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:56:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#take_failed_screenshot'
/home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:10:in 'ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown#before_teardown'
Reproduce
Requirements to reproduce:
To reproduce the error clone this repo and in its root directory run bin/rails test:all. The repo is minimal and simply does the following:
- Create a new Rails project
- Generate 1 view with an
h1 tag with text "Hello, Rails!"
- Create a basic
test/application_system_test_case.rb to setup selenium
- Generate 1 system test to assert the text in the
h1 tag is "Hello, Rails!"
Relevant context
Selenium Manager (bundled with the selenium-webdriver gem) has a hardcoded list of Chrome binary paths it checks on Linux: /usr/bin/google-chrome, /usr/bin/google-chrome-beta, /usr/bin/google-chrome-unstable. Arch Linux via the AUR google-chrome package installs /usr/bin/google-chrome-stable. There's no plain /usr/bin/google-chrome so Selenium Manager can't detect the installed Chrome at all, falls back to downloading whatever the latest Chrome-for-Testing release is (version 151, which is the latest "Early" stable release) to decide which ChromeDriver to fetch, while the actual browser that ends up launching is found separately by ChromeDriver's own (more permissive) binary search, which does find /opt/google/chrome/chrome (version 150, which is the actual latest stable release). Hence the version mismatch that produces the error.
This is verified by running the Rails tests then checking the downloaded ChromeDriver in Selenium's cache directory and you'll find it doesn't match the version of the locally installed Chrome since it didn't find it and simply downloads the driver for the latest stable Chrome for Testing:
~/.cache/selenium/chromedriver/linux64/151.0.7922.47
However, Selenium Manager detects the correct Chrome version and downloads the matching driver if you create a symbolic link at one of the locations that it looks for:
# Create symbolic link at a location Selenium Manager looks for
sudo ln -s /usr/bin/google-chrome-stable /usr/bin/google-chrome
# Run the Rails tests which triggers the download of the chrome driver
bin/rails test:all
# You'll find the correct driver version is downloaded in Selenium's cache directory
~/.cache/selenium/chromedriver/linux64/150.0.7871.124
Proposed fix
Add /usr/bin/google-chrome-stable to the list of paths that Selenium Manager checks on Linux.
Reproducible Code
https://github.com/bglogic/ruby-selenium-webdriver-arch-bug
Description
Overview
In Arch Linux I was trying to use
selenium-webdriverto test content on a page but I got an error instead. This error also happens on a freshly created Rails project.Stacktrace
Error: WelcomesTest#test_visiting_the_index: Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 151 Current browser version is 150.0.7871.186 with binary path /opt/google/chrome/chrome test/system/welcomes_test.rb:5:in 'block in <class:WelcomesTest>' Error: WelcomesTest#test_visiting_the_index: Selenium::WebDriver::Error::SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 151 Current browser version is 150.0.7871.186 with binary path /opt/google/chrome/chrome /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:63:in 'Selenium::WebDriver::Remote::Response#add_cause' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:41:in 'Selenium::WebDriver::Remote::Response#error' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:52:in 'Selenium::WebDriver::Remote::Response#assert_ok' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/response.rb:34:in 'Selenium::WebDriver::Remote::Response#initialize' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/common.rb:148:in 'Selenium::WebDriver::Remote::Http::Common#create_response' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/default.rb:122:in 'Selenium::WebDriver::Remote::Http::Default#request' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/http/common.rb:87:in 'Selenium::WebDriver::Remote::Http::Common#call' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/bridge.rb:631:in 'Selenium::WebDriver::Remote::Bridge#execute' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/remote/bridge.rb:69:in 'Selenium::WebDriver::Remote::Bridge#create_session' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:325:in 'block in Selenium::WebDriver::Driver#create_bridge' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:324:in 'Kernel#tap' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:324:in 'Selenium::WebDriver::Driver#create_bridge' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:73:in 'Selenium::WebDriver::Driver#initialize' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/chrome/driver.rb:35:in 'block in Selenium::WebDriver::Chrome::Driver#initialize' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/local_driver.rb:32:in 'Selenium::WebDriver::LocalDriver#initialize_local_driver' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/chrome/driver.rb:34:in 'Selenium::WebDriver::Chrome::Driver#initialize' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver/common/driver.rb:47:in 'Selenium::WebDriver::Driver.for' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/selenium-webdriver-4.46.0/lib/selenium/webdriver.rb:88:in 'Selenium::WebDriver.for' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/selenium/driver.rb:75:in 'Capybara::Selenium::Driver#browser' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:57:in 'block in ActionDispatch::SystemTesting::Driver#register_selenium' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:56:in 'Kernel#tap' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:56:in 'ActionDispatch::SystemTesting::Driver#register_selenium' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/driver.rb:43:in 'block in ActionDispatch::SystemTesting::Driver#register' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/session.rb:106:in 'Capybara::Session#driver' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/session.rb:92:in 'Capybara::Session#initialize' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara.rb:422:in 'block in Capybara.session_pool' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara.rb:317:in 'Capybara.current_session' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/capybara-3.40.0/lib/capybara/dsl.rb:46:in 'Capybara::DSL#page' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:116:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#save_image' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:46:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#take_screenshot' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:56:in 'ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper#take_failed_screenshot' /home/bglogic/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/actionpack-8.1.3/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:10:in 'ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown#before_teardown'Reproduce
Requirements to reproduce:
To reproduce the error clone this repo and in its root directory run
bin/rails test:all. The repo is minimal and simply does the following:h1tag with text "Hello, Rails!"test/application_system_test_case.rbto setup seleniumh1tag is "Hello, Rails!"Relevant context
Selenium Manager (bundled with the
selenium-webdrivergem) has a hardcoded list of Chrome binary paths it checks on Linux:/usr/bin/google-chrome,/usr/bin/google-chrome-beta,/usr/bin/google-chrome-unstable. Arch Linux via the AURgoogle-chromepackage installs/usr/bin/google-chrome-stable. There's no plain/usr/bin/google-chromeso Selenium Manager can't detect the installed Chrome at all, falls back to downloading whatever the latest Chrome-for-Testing release is (version 151, which is the latest "Early" stable release) to decide which ChromeDriver to fetch, while the actual browser that ends up launching is found separately by ChromeDriver's own (more permissive) binary search, which does find/opt/google/chrome/chrome(version 150, which is the actual latest stable release). Hence the version mismatch that produces the error.This is verified by running the Rails tests then checking the downloaded ChromeDriver in Selenium's cache directory and you'll find it doesn't match the version of the locally installed Chrome since it didn't find it and simply downloads the driver for the latest stable Chrome for Testing:
~/.cache/selenium/chromedriver/linux64/151.0.7922.47However, Selenium Manager detects the correct Chrome version and downloads the matching driver if you create a symbolic link at one of the locations that it looks for:
Proposed fix
Add
/usr/bin/google-chrome-stableto the list of paths that Selenium Manager checks on Linux.Reproducible Code