webdrivers
webdrivers copied to clipboard
Use snap driver when chromium is installed via snap package
Summary
The downloaded chromedriver doesn't work with Chromium installed via snap package (as written here: https://github.com/titusfortner/webdrivers/wiki/Chrome-snap-package-hangs).
The solution pointed in the wiki suggests installing Chromium via apt, but it isn't an easy option as Ubuntu doesn't provide an apt flavour of Chromium and the unofficial alternatives are unreliable (for example, the one linked in the issue related to the wiki page is marked as abandoned: https://launchpad.net/~xalt7x/+archive/ubuntu/chromium-deb-vaapi).
Anyway, The snap flavour of chromedriver works fine together with snap Chromium. So I suggest to detect that Chromium is installed via snap (I guess it is possible to check that the Chromium path starts with /snap/
) and, in this case, skip chromedriver installation and use the snap chromedriver (or tell the user to install it). I'm open to work on a pull request, if welcome.
My current workaround is to overwrite the chromedriver path set by webdrivers
:
::Selenium::WebDriver::Chrome::Service.driver_path = proc { '/snap/bin/chromium.chromedriver' }
Debug Info
- Webdrivers version: 4.6.1
- Ruby version: 3.0.2
- Operating system / CI Environment: Linux Ubuntu 20.04.2
- Browser and version:
- Chromium 93.0.4577.82 snap
- ChromeDriver 93.0.4577.82 (e3a25d9b9e2d0b728e045ec87c0aa4942aa46e4e-refs/branch-heads/4577@{#1237})
Expected Behavior
I expect Webdrivers to detect that Chromium is installed via snap and to set the related chromedriver accordingly, rather than downloading and hanging during tests running.
Actual Behavior
Well, I guess I can write here the error log when using snap Chromium together with the downloaded driver:
> RAILS_ENV=test bin/rails test:system
Running 4 tests in a single process (parallelization threshold is 50)
Run options: --seed 32101
Running:
E
Error:
PagesTest#test_should_destroy_Page:
Selenium::WebDriver::Error::UnknownError: unknown error: DevToolsActivePort file doesn't exist
test/system/pages_test.rb:40:in `block in class:PagesTest'
Error:
PagesTest#test_should_destroy_Page:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:219:in rbuf_fill' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:193:in
readuntil'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:203:in readline' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:42:in
read_status_line'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:31:in read_new' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1557:in
block in transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in catch' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in
transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1521:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in
response_for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in
call'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in execute' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:102:in
create_session'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:56:in handshake' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/chrome/driver.rb:43:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in
for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in for' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:83:in
browser'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:60:in block in register_selenium' <internal:kernel>:90:in
tap'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:59:in register_selenium' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:45:in
block in register'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:104:in driver' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:90:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in
block in session_pool'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:315:in current_session' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/dsl.rb:46:in
page'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:99:in save_image' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:36:in
take_screenshot'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:45:in take_failed_screenshot' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:16:in
before_teardown'
rails test test/system/pages_test.rb:39
E
Error:
PagesTest#test_visiting_the_index:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
test/system/pages_test.rb:11:in `block in class:PagesTest'
Error:
PagesTest#test_visiting_the_index:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:219:in rbuf_fill' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:193:in
readuntil'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:203:in readline' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:42:in
read_status_line'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:31:in read_new' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1557:in
block in transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in catch' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in
transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1521:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in
response_for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in
call'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in execute' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:102:in
create_session'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:56:in handshake' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/chrome/driver.rb:43:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in
for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in for' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:83:in
browser'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:60:in block in register_selenium' <internal:kernel>:90:in
tap'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:59:in register_selenium' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:45:in
block in register'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:104:in driver' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:90:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in
block in session_pool'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:315:in current_session' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/dsl.rb:46:in
page'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:99:in save_image' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:36:in
take_screenshot'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:45:in take_failed_screenshot' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:16:in
before_teardown'
rails test test/system/pages_test.rb:10
E
Error:
PagesTest#test_should_create_Page:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
test/system/pages_test.rb:16:in `block in class:PagesTest'
Error:
PagesTest#test_should_create_Page:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:219:in rbuf_fill' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:193:in
readuntil'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:203:in readline' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:42:in
read_status_line'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:31:in read_new' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1557:in
block in transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in catch' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in
transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1521:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in
response_for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in
call'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in execute' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:102:in
create_session'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:56:in handshake' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/chrome/driver.rb:43:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in
for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in for' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:83:in
browser'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:60:in block in register_selenium' <internal:kernel>:90:in
tap'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:59:in register_selenium' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:45:in
block in register'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:104:in driver' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:90:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in
block in session_pool'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:315:in current_session' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/dsl.rb:46:in
page'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:99:in save_image' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:36:in
take_screenshot'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:45:in take_failed_screenshot' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:16:in
before_teardown'
rails test test/system/pages_test.rb:15
E
Error:
PagesTest#test_should_update_Page:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
test/system/pages_test.rb:28:in `block in class:PagesTest'
Error:
PagesTest#test_should_update_Page:
Net::ReadTimeout: Net::ReadTimeout with #TCPSocket:(closed)
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:219:in rbuf_fill' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:193:in
readuntil'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/protocol.rb:203:in readline' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:42:in
read_status_line'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http/response.rb:31:in read_new' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1557:in
block in transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in catch' .asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1548:in
transport_request'
.asdf/installs/ruby/3.0.2/lib/ruby/3.0.0/net/http.rb:1521:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in
response_for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in request' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in
call'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in execute' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:102:in
create_session'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:56:in handshake' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/chrome/driver.rb:43:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in
for'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in for' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/selenium/driver.rb:83:in
browser'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:60:in block in register_selenium' <internal:kernel>:90:in
tap'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:59:in register_selenium' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/driver.rb:45:in
block in register'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:104:in driver' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/session.rb:90:in
initialize'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in new' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:424:in
block in session_pool'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara.rb:315:in current_session' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/capybara-3.35.3/lib/capybara/dsl.rb:46:in
page'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:99:in save_image' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:36:in
take_screenshot'
.asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:45:in take_failed_screenshot' .asdf/installs/ruby/3.0.2/lib/ruby/gems/3.0.0/gems/actionpack-7.0.0.alpha2/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:16:in
before_teardown'
rails test test/system/pages_test.rb:27
Finished in 482.678138s, 0.0083 runs/s, 0.0000 assertions/s.
4 runs, 0 assertions, 0 failures, 4 errors, 0 skips
Can you set the desired location of your Chromium binary with:
ENV["WD_CHROME_PATH"]
I have the same issue. I tried setting WD_CHROME_PATH
to /snap/bin/chromium.chromedriver'
, '/snap/bin/chromium'
and '/snap/bin/'
with equally poor results.
Seems that the only way to get it to work was setting the driver_path
to the chromium.chromedriver
that was installed with snap install chromium
.
@entretechno-jeremiah re: #225
Can you set Selenium::WebDriver::Chrome.path = "/snap/chromium/current/usr/lib/chromium-browser/chrome"
and see if the driver downloaded by webdrivers works? The problem in the original issue (#168) was that chromium
was hanging when webdrivers tried to retrieve its version. I don't have a linux machine at hand to test this, but I think chromedriver
itself should work and not be the problem here. It's the wrapper which was problematic and the using the underlying binary worked when I tried.
In any case, I am not keen on merging #225 in its current form because it's adding browser specific logic in Common#update
. If the above doesn't work then we're pretty much looking at overriding what webdrivers is at its core and blindly returning whatever driver we find in /snap/bin
without performing any compatibility checks, which is oof...
@kapoorlakshya
Can you set
Selenium::WebDriver::Chrome.path = "/snap/chromium/current/usr/lib/chromium-browser/chrome"
and see if the driver downloaded by webdrivers works?
That works! If I submitted a PR to set Selenium::WebDriver::Chrome.path = ENV['WD_CHROME_PATH']
, how would you feel about that? I understand if that's maybe not the concern of this library.
@entretechno-jeremiah Great! How about you just set WD_CHROME_PATH=/snap/chromium/current/usr/lib/chromium-browser/chrome
in your dev/test environment so webdrivers can read the product version from that binary and download a compatible driver. Selenium can continue to use the wrapper/shim from snap
and everything should work as expected.
@kapoorlakshya I thought I had tried that and it didn't work; but I tried it again and it does work. Sorry about that! And thanks for all your help!
@entretechno-jeremiah No problem! Glad we figured it out.
@mdesantis @pgwillia Please give the above a try and confirm if it works for you as well. I'd like to close this ticket and document the workaround in the wiki once we have multiple confirmations. Thanks!
@kapoorlakshya Sorry again; I was right the first time that it didn't work. I had made a change to my local version of this library and forgot about it before I re-ran my tests. So setting WD_CHROME_PATH
by itself does not work; it only works if I also set Selenium::WebDriver::Chrome.path
. Once again sorry for the back-and-forth.
I've spent a lot of time looking at this over the past few days, and I think this is due to much deeper problems with the Chromium Snap package or Snap itself (as discussed in #168). Until that's fixed (:crossed_fingers:), I'm going to use this hacky workaround:
sudo ln -s /snap/chromium/current/usr/lib/chromium-browser/chrome /usr/local/bin/google-chrome
This works because /usr/local/bin
is one of the directories in which chromedriver looks for a binary (gotta love that // TODO: Respect users' PATH variables.
:sweat_smile:) and google-chrome
is one of the binary names it looks for (this is what Webdrivers::ChromeFinder
is based on). I don't have any existing google-chrome
binaries in my PATH, which leads me to believe that would only happen if you install Chrome instead of Chromium; so hopefully the only outcome of creating that symlink is tricking chromedriver into using that instead of /snap/bin/chromium
. I haven't noticed any problems so far; I'm still able to use Chromium normally.
@kapoorlakshya How would you feel about a PR to set a WEBDRIVERS=1
env var when this launches chromedriver so that I could replace that symlink with a script that conditionally executes the right binary depending on whether it was called via this library or not? That way we hopefully wouldn't have to worry about any side effects of that symlink, and you could document it as an official workaround (pending confirmation from other users). Thanks again for all your work on this!
@entretechno-jeremiah No worries, happy to keep troubleshooting.
So setting WD_CHROME_PATH by itself does not work;
Did it hang or was there an error?
I like the symlink idea, but I am not sure if setting ENV['WEBDRIVERS'] =1
from webdrivers will make it available to contexts outside of it (i.e. your script). My understanding is that it will only set it for the ruby process that sets is. Can you give it a try and report back if it works? I don't see any harm in setting that env var if it helps resolve this issue.
So... I just set up WSL2 w/ Ubuntu 20.04.3 to reproduce this issue and I am no longer able to. Chromium (installed via snap) returns the version without hanging and chromedriver is successfully downloaded.
kapoorlakshya@LK-Desktop:~/src/webdrivers$ bin/console
irb(main):001:0> Webdrivers.logger.level = :DEBUG
=> :DEBUG
irb(main):002:0> Webdrivers::ChromeFinder.location
=> "/snap/bin/chromium"
irb(main):003:0> Webdrivers::ChromeFinder.version
2022-01-22 19:39:41 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:39:41 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:39:41 DEBUG Webdrivers Browser version: 97.0.4692.99
=> "97.0.4692.99"
irb(main):004:0> Webdrivers::Chromedriver.update
2022-01-22 19:39:59 DEBUG Webdrivers Checking current version
2022-01-22 19:39:59 DEBUG Webdrivers /home/kapoorlakshya/.webdrivers/chromedriver is not already downloaded
2022-01-22 19:39:59 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:39:59 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:39:59 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:39:59 DEBUG Webdrivers Checking current version
2022-01-22 19:39:59 DEBUG Webdrivers /home/kapoorlakshya/.webdrivers/chromedriver is not already downloaded
2022-01-22 19:39:59 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:40:00 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:40:00 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:40:00 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:40:00 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:40:00 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:40:00 DEBUG Webdrivers Making network call to https://chromedriver.storage.googleapis.com/LATEST_RELEASE_97.0.4692
2022-01-22 19:40:00 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
2022-01-22 19:40:00 DEBUG Webdrivers Latest version available: 97.0.4692.71
2022-01-22 19:40:00 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:40:01 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers /home/kapoorlakshya/.webdrivers/chromedriver is not already downloaded
2022-01-22 19:40:01 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:40:01 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers making System call: ["/snap/bin/chromium", "--product-version"]
2022-01-22 19:40:01 DEBUG Webdrivers System call returned: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers Browser version: 97.0.4692.99
2022-01-22 19:40:01 DEBUG Webdrivers Making network call to https://chromedriver.storage.googleapis.com/LATEST_RELEASE_97.0.4692
2022-01-22 19:40:01 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
2022-01-22 19:40:01 DEBUG Webdrivers Latest version available: 97.0.4692.71
2022-01-22 19:40:01 DEBUG Webdrivers chromedriver URL: https://chromedriver.storage.googleapis.com/97.0.4692.71/chromedriver_linux64.zip
2022-01-22 19:40:01 DEBUG Webdrivers Making network call to https://chromedriver.storage.googleapis.com/97.0.4692.71/chromedriver_linux64.zip
2022-01-22 19:40:02 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
2022-01-22 19:40:02 DEBUG Webdrivers Successfully downloaded /tmp/20220122-3351-1dt8xz3chromedriver_linux64.zip
2022-01-22 19:40:02 DEBUG Webdrivers Decompressing /tmp/20220122-3351-1dt8xz3chromedriver_linux64.zip
2022-01-22 19:40:02 DEBUG Webdrivers Completed download and processing of /home/kapoorlakshya/.webdrivers/chromedriver
=> "/home/kapoorlakshya/.webdrivers/chromedriver"
irb(main):006:0> Webdrivers::Chromedriver.current_version
2022-01-22 19:40:22 DEBUG Webdrivers Checking current version
2022-01-22 19:40:22 DEBUG Webdrivers /home/kapoorlakshya/.webdrivers/chromedriver is already downloaded
2022-01-22 19:40:22 DEBUG Webdrivers making System call: ["/home/kapoorlakshya/.webdrivers/chromedriver", "--version"]
2022-01-22 19:40:22 DEBUG Webdrivers System call returned: ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247})
2022-01-22 19:40:22 DEBUG Webdrivers Current version of /home/kapoorlakshya/.webdrivers/chromedriver is ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247})
=> #<Gem::Version "97.0.4692.71">
I followed the instructions here to install chromium - https://snapcraft.io/install/chromium/ubuntu#install
What version of Ubuntu and Chromium are you using? Either I am missing something or snap fixed this in the recent version(s).
@kapoorlakshya
Did it hang or was there an error?
It hangs - not when getting the version as originally reported, but when actually running the tests and when attempting to exit the browser. I've created entretechno/webdrivers-217 as a test case for this; here's the output of bin/rails test:system
:
Running 1 tests in a single process (parallelization threshold is 50)
Run options: --seed 12603
# Running:
DEBUGGER: Attaching after process 1430193 fork to child process 1430362
DEBUGGER[bin/rails#1430597]: Attaching after process 1430193 fork to child process 1430597
E
Error:
HomeTest#test_visiting_home:
Selenium::WebDriver::Error::UnknownError: unknown error: DevToolsActivePort file doesn't exist
test/system/home_test.rb:5:in `block in <class:HomeTest>'
Error:
HomeTest#test_visiting_home:
Selenium::WebDriver::Error::UnknownError: unknown error: DevToolsActivePort file doesn't exist
#0 0x55cce7bf9a23 <unknown>
#1 0x55cce76c4e18 <unknown>
#2 0x55cce76eae12 <unknown>
#3 0x55cce76e734d <unknown>
#4 0x55cce76e391a <unknown>
#5 0x55cce771e74a <unknown>
#6 0x55cce7718883 <unknown>
#7 0x55cce76ee3fa <unknown>
#8 0x55cce76ef4c5 <unknown>
#9 0x55cce7c2916d <unknown>
#10 0x55cce7c3f5bb <unknown>
#11 0x55cce7c2ae75 <unknown>
#12 0x55cce7c3fe85 <unknown>
#13 0x55cce7c1e86f <unknown>
#14 0x55cce7c5aae8 <unknown>
#15 0x55cce7c5ac68 <unknown>
#16 0x55cce7c75aad <unknown>
#17 0x7fad4bbd2927 <unknown>
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/response.rb:56:in `assert_ok'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/response.rb:35:in `initialize'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/default.rb:109:in `request'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:588:in `execute'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/remote/bridge.rb:52:in `create_session'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:340:in `create_bridge'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:74:in `initialize'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:47:in `new'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver/common/driver.rb:47:in `for'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/selenium-webdriver-4.1.0/lib/selenium/webdriver.rb:88:in `for'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara/selenium/driver.rb:83:in `browser'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/driver.rb:64:in `block in register_selenium'
<internal:kernel>:90:in `tap'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/driver.rb:63:in `register_selenium'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/driver.rb:49:in `block in register'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara/session.rb:104:in `driver'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara/session.rb:90:in `initialize'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara.rb:419:in `new'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara.rb:419:in `block in session_pool'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara.rb:315:in `current_session'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/capybara-3.36.0/lib/capybara/dsl.rb:46:in `page'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:99:in `save_image'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:36:in `take_screenshot'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:45:in `take_failed_screenshot'
/home/jm/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionpack-7.0.1/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb:8:in `before_teardown'
rails test test/system/home_test.rb:4
Finished in 120.628254s, 0.0083 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
It then hangs until I run killall chromedriver
.
What version of Ubuntu and Chromium are you using?
Ubuntu 21.10 / Chromium 97.0.4692.99
Submitted #227 for the WEBDRIVERS=1
env var. Here's the script I plan to save to /usr/local/bin/chromium
if that's accepted:
#!/usr/bin/env sh
if [ -n "$WEBDRIVERS" ]; then
exec /snap/chromium/current/usr/lib/chromium-browser/chrome "$@"
else
exec /snap/bin/chromium "$@"
fi
@entretechno-jeremiah Interesting... I think that since webdrivers is able to do its job successfully, solving what you're seeing would fall outside the scope of this gem.
Can you please remind me why we can't just set Selenium::WebDriver::Chrome.path = '/snap/chromium/current/usr/lib/chromium-browser/chrome'
in your tests to make them work? webdrivers shouldn't need anything special now that it's able to successfully use /snap/bin/chromium
. Right?
If you already know the path to an existing driver that you want to use, you can pass it in to Selenium's Service class and it will ignore webdrivers gem entirely.
Can re-open if an alternate use case is provided.
This gem is generally consistent in approach between different browsers/drivers/platforms. Anything done in the gem to accommodate a custom browser implementation that has a custom driver is going to be a hack.
Whether to support a hack at all mostly comes down to how many people need it, and based on the conversations it appears this is a sufficiently popular request.
If someone wants to make a PR to subclass the #update
method for Chrome to check if it's a snap installation and return the full path of the snap driver, I'll merge it.