jeudi 22 mars 2018

Headless Chrome Blank White Screen

I've currently got a Rails application trying to get headless chrome working for testing.

Capybara Version: 2.15.1

Selenium Webdriver: 3.11.0

Using docker image below: https://github.com/SeleniumHQ/docker-selenium**

Without the headless option, I see the browser boots up and the tests run without a problem. However, when I add the headless argument to the capabilities, the tests consistently fail with unable to find element. When I look at the screenshots/html, all I see are blank webpages like such and the PNG screenshot is a completely blank white screen.

<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body></body></html>

Here is the selenium helper file I'm using to setup the drivers.

Capybara.register_driver :remote_browser do |app|
  selenium = ENV.fetch('SELENIUM_ADDR', 'selenium')

  WebMock.disable_net_connect!(
    :allow => [
      'api.knapsackpro.com',
      selenium,
      Capybara.server_host,
    ],
  )

  capabilities = {
    "browserName" => "chrome",
    "goog:chromeOptions" => {
      args: %w[headless disable-gpu window-size=19280,1080 no-sandbox]
    }
  }

  Capybara::Selenium::Driver.new(app, browser: :remote, url: "http://#{selenium}:4444/wd/hub", desired_capabilities: capabilities)
end
Capybara.javascript_driver = :remote_browser

Capybara::Screenshot.register_driver(:remote_browser) do |driver, path|
  driver.browser.save_screenshot(File.join('..', path))
end

Aucun commentaire:

Enregistrer un commentaire