Define your test
script and include Chrome buildpacks:
{
"environments": {
"test": {
"addons": [
"heroku-postgresql"
],
"scripts": {
"test": "rails test:system"
},
"buildpacks": [
{ "url": "heroku/ruby" },
{ "url": "https://github.com/heroku/heroku-buildpack-google-chrome" },
{ "url": "https://github.com/heroku/heroku-buildpack-chromedriver" }
]
}
}
}
Define new Capybara driver that uses buildpack's Chrome binaries during a Heroku CI run:
# tell Heroku CI run where to find chrome binary
# https://github.com/heroku/heroku-buildpack-google-chrome#selenium
chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil)
chrome_opts = chrome_bin ? { "chromeOptions" => { "binary" => chrome_bin } } : {}
Capybara.register_driver :chrome_shim do |app|
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(chrome_opts)
)
end
Capybara.javascript_driver = :chrome_shim
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :chrome_shim
end
Related to a recent config change in chromedriver that's not yet working nicely.
# Gemfile
group :test do
gem 'selenium-webdriver', '3.12.0'
...