Starting the browser connections result in InvalidArgumentError with Docker/Chrome headless

72 views
Skip to first unread message

Juan Gabardini

unread,
Jan 4, 2021, 10:37:37 AM1/4/21
to Capybara
Hi

I'm testing a Rails 3.2 app with docker  & chrome.
I could connect to the headless browser / root with Selenium/Webdriver. But it doesn't connect with Capybara.
My hypothesis is that Capybara has some problem with the args, but I had a look at it and haven't found anything 


I’m getting this error (the line is a visit '...')

    Given Im a logged in user                         # features/step_definitions/web_steps.rb:21
      invalid argument
        (Session info: headless chrome=87.0.4280.88) (Selenium::WebDriver::Error::InvalidArgumentError)
      #0 0x55efaa4d2e79 <unknown>

In env.rb we have
Webdrivers::Chromedriver.required_version = '87.0.4280.88'
Capybara.default_selector = :css
Capybara.javascript_driver = :selenium
Capybara.run_server = false

Capybara.register_driver :selenium do |app|
  options = Selenium::WebDriver::Chrome::Options.new(
    args: %w[--headless --no-sandbox] # --disable-gpu --disable-dev-shm-usage --disable-setuid-sandbox --disable-web-security --disable-popup-blocking --window-size=1920,1080]
  )
  Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end


If I try this code in env.rb, it works
require 'webdrivers'
  Webdrivers::Chromedriver.required_version = '87.0.4280.88'
  options = Selenium::WebDriver::Chrome::Options.new(
    args: %w[--headless --no-sandbox]
  )
  driver=Selenium::WebDriver.for :chrome, options: options
  driver.get 'http://www.google.com'
  p driver

Shows

#<Selenium::WebDriver::Chrome::Driver:0x76555a9ccfe3615c browser=:chrome>


In the Gemfile.lock

   ruby 2.3.8p459
    rails (3.2.22.5)
    capybara (2.18.0)
    cucumber-rails (1.4.0)
    selenium-webdriver (3.142.7)
    webdrivers (4.2.0)



Thanks!
-- 
Juan 

Reply all
Reply to author
Forward
0 new messages