2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Dokcer環境等で発生するSelenium::WebDriver::Error::UnknownErrorの対処法

Posted at

Dokcer環境などのCUI環境でcapybara/selenium/chromedriverを利用する際は no-sandbox/disable-dev-shm-usageオプションが必要

Selenium::WebDriver::Error::UnknownError:
                unknown error: Chrome failed to start: exited abnormally.
                  (unknown error: DevToolsActivePort file doesn't exist)
                  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
capybara.rb
...
Capybara.register_driver :selenium_chrome_headless do |app|
  options = ::Selenium::WebDriver::Chrome::Options.new
  options.add_argument('--headless') 
  options.add_argument('--no-sandbox') # chrootで隔離された環境(Sandbox)での動作を無効
  options.add_argument('--disable-dev-shm-usage') # 共有メモリファイルの場所を/dev/shmから/tmpに移動
  options.add_argument('--disable-gpu')
  options.add_argument('--window-size=2500,2500')
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end

Capybara.javascript_driver = :selenium_chrome_headless
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?