L'option no-sandbox / disable-dev-shm-usage
est requise lors de l'utilisation de capybara / selenium / chromedriver dans un environnement CUI tel que l'environnement Dokcer.
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') #environnement isolé par chroot(Sandbox)Désactive le fonctionnement dans
options.add_argument('--disable-dev-shm-usage') #L'emplacement du fichier de mémoire partagée/dev/de shm/Déplacer vers 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