Getting Started with Headless Chrome


636
636 points
headless chrome
headless chrome

Getting Started with Headless Chrome

Headless chrome is delivered in Chrome 59. It allows you to run the Chrome browser in a headless environment.

A headless browser is a great tool for automated testing and server environments where you don’t need a visible UI shell.

A while ago I wrote an article how to run tests on chrome headless using docker  but now you can make the new changes in your project.

Advertisements
Start chrome headless
Capybara.register_driver :chrome_headless do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    chromeOptions: {
      args: %w[ no-sandbox headless disable-gpu ]
    }
  )

  Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
end

Also you should set default_driver instead of current_driver.

Capybara.configure do |config|
  config.run_server = false
  config.default_driver = :selenium
  config.app_host = 'https://www.google.com' # change url
end

For more informations about chrome headless you should check this out.

Happy Testing!


Like it? Share with your friends!

636
636 points
Test engineer

0 Comments

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.