How to deal with Selenium :: WebDriver :: Error :: UnknownError that occurs in Dokcer environment etc.

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

How to deal with Selenium :: WebDriver :: Error :: UnknownError that occurs in Dokcer environment etc.
How to deal with the error yaml.scanner.ScannerError: while scanning for the next token that appeared in Rails environment construction with Docker
How to deal with 405 Method Not Allowed error in Tomcat + JSP
How to deal with SQLite3 :: BusyException that occurs when uploading a large number of images using ActiveStorage in seeds.rb etc.
How to deal with the event that Committee :: InvalidRequest occurs in committee during Rspec file upload test
[Docker environment] How to deal with ActiveSupport :: MessageEncryptor :: InvalidMessage
`bind': Address already in use --bind (2) for 127.0.0.1:3000 (Errno :: EADDRINUSE) How to deal with the error
[Ruby] 5 errors that tend to occur when scraping with Selenium and how to deal with them
How to deal with the error ERROR: While executing gem ... (Gem :: FilePermissionError)
[Rails / RSpec] How to deal with element has zero size error
[Rails] How to execute "rails db: create" etc. in production environment EC2
How to execute with commands of normal development language in Docker development environment
What to do and how to install when an error occurs in DXRuby 1.4.7
How to reflect seeds.rb in production environment
How to use environment variables in RubyOnRails
How to deal with Precompiling assets failed.
How to build Rails 6 environment with Docker
How to display error messages in Japanese
[Laravel] How to deal with out of memory error when composer require [Docker]
[Error resolution] Occurs when trying to build an environment for spring with docker
Summary of how to select elements in Selenium
How to install Titan2D (v4.2.0) in virtual environment
500 Internal Server Error occurs in Rails production environment
[Rails] How to build an environment with Docker
[Rails] How to use PostgreSQL in Vagrant environment
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
How to deal with errors in Rails s could not find a JavaScript runtime.
How to embed JavaScript variables in HTML with Thymeleaf
How to implement UICollectionView in Swift with code only
How to call functions in bulk with Java reflection
How to create a Java environment in just 3 seconds
Diet program with preprocessor (how to deal with i-appli size)
How to switch Tomcat context.xml with WTP in Eclipse
How to deal with fatal: remote origin already exists.
How to use Z3 library in Scala with Eclipse
How to install geckodriver (Selenium WebDriver) automatically using WebDriverManager
[How to insert a video in haml with Rails]
[Rails] How to deal with URL changes after render
How to delete untagged images in bulk with Docker
How to use JDD library in Scala with Eclipse
How to test file upload screen in Spring + Selenium
How to build Java development environment with VS Code
How to query Array in jsonb with Rails + postgres
How to boot by environment with Spring Boot of Maven
Common problems with WSL and how to deal with them
[Docker + Rails] How to deal with Rails server startup failure
How to resolve SSL_connect error in PayPal Ruby SDK
How to get jdk etc from oracle with cli
How to manage the difference in each environment with yml without increasing the number of RAILS_ENV