Stepan Salin
Stepan Salin

Reputation: 179

Selenium + Capybara: run Chrome with parameters in Ubuntu

While being run in a container, Chrome can throw exception, something about PIDs and totally not related to the question at hand.

To solve this, you have to run chrome like:

google-chrome --no-sandbox --user-data-dir /root

Question is, how do i pass the --no-sandbox --user-data-dir /root part to Capybara and/or Selenium.

This is how i register my driver

Capybara.register_driver :chrome do |app|
  require 'selenium/webdriver'
  Selenium::WebDriver::Chrome.driver_path =     ENV['CHROMEDRIVER_EXECUTABLE']
  Capybara::Selenium::Driver.new(
   app,
   :browser => :chrome,
   desired_capabilities: {
      "chromeOptions" => {
       "args" => %w{ window-size=1920,1080 }
     }
    }
  )
end

Thanks!

Upvotes: 2

Views: 682

Answers (1)

Thomas Walpole
Thomas Walpole

Reputation: 49890

You just add more options to args

"args" => %w{ window-size=1920,1080 no-sandbox user-data-dir=/root }

Upvotes: 1

Related Questions