The no-sandbox / disable-dev-shm-usage
option is required when using capybara / selenium / chromedriver in a CUI environment such as the Dokcer environment.
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 isolated environment(Sandbox)Disables operation in
options.add_argument('--disable-dev-shm-usage') #The location of the shared memory file/dev/from shm/Move to 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
Recommended Posts