When trying to use the selenium/standalone-chrome image with rails I got a very annoying error and the cause is still unknown. But it was resolved by replacing it with another image.
Here is what happened.
Environment
# docker-compose.yml
version: '3.9'
services:
web:
# ...
db:
# ...
webdriver_chrome:
image: selenium/standalone-chromium:117.0
ports:
- 4444:4444
- 5900:5900
# spec/support/capybara.rb
Capybara.register_driver :remote_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1400,1400')
Capybara::Selenium::Driver.new(
app,
browser: :remote,
url: ENV['SELENIUM_REMOTE_HOST'],
options:
)
end
RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by :rack_test
end
config.before(:each, type: :system, js: true) do
if ENV['SELENIUM_REMOTE_HOST'].present?
Capybara.server_host = IPSocket.getaddress(Socket.gethostname)
Capybara.app_host = "http://#{Capybara.server_host}"
driven_by :remote_chrome
else
driven_by :selenium_chrome_headless
end
end
end
Errors
Selenium::WebDriver::Error::SessionNotCreatedError:
Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
How to temporarily fix it!
Replacing selenium/standalone-chromium:117.0
with seleniarm/standalone-chromium:117.0
- image: selenium/standalone-chromium:117.0
+ image: seleniarm/standalone-chromium:117.0
Top comments (0)