Created
September 28, 2020 22:45
-
-
Save metaskills/c988b6895f8c7f704472460f93b4a034 to your computer and use it in GitHub Desktop.
Rails Capybara System Tests Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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