Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.