Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created September 28, 2020 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/c988b6895f8c7f704472460f93b4a034 to your computer and use it in GitHub Desktop.
Save metaskills/c988b6895f8c7f704472460f93b4a034 to your computer and use it in GitHub Desktop.
Rails Capybara System Tests Setup
# Gemfile
gem 'selenium-webdriver'
# test/application_system_test_case.rb (or capy setup file)
require 'test_helper'
Capybara.server = :webrick
Webdrivers::Chromedriver.required_version = '2.36'
driver_path = Webdrivers::Chromedriver.update
Selenium::WebDriver::Chrome::Service.driver_path = driver_path
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
Capybara.register_driver :headless_chrome do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
'chromeOptions' => {
'args' => ['headless', 'disable-gpu', 'no-sandbox', 'window-size=1280,1024'],
'binary' => ENV['GOOGLE_CHROME_SHIM']
}.reject { |_k, v| v.nil? }
)
)
end
driven_by :headless_chrome
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment