Closed hirowatari closed 5 years ago
It's not that it's not downloading the driver - it's that it's not finding Chrome. Where is Chrome installed on the system?
Oh - you're running the selenium standalone chrome docker image via a remote selenium connection? Then you shouldn't be running webdrivers on the local machine.
I didn't realize I didn't need this gem if I was using a remote connection. Thanks for pointing that out. Much appreciated.
@hirowatari would you mind sharing your docker-compose.yml
and Dockerfile
relating to your test setup? Curious how you wired this up. Pulling my hair setting up end-to-end (i.e. system) tests with the selenium Docker images. Would appreciate!
@klausbadelt I second that request @hirowatari. I have been fighting this in the Jenkins pipeline, although I was doing it without the external selenium container. I would like to keep it inline.
I'm not sure how helpful I'll be since my setup may be too specific for my needs and I may not remember all the things I had to do to get it to work, but this may be a good starting point. Let me know if you thing I'm missing something (preferably in the gist since we're fairly far off topic here).
https://gist.github.com/hirowatari/832658c3ffdc476db44436d2e0ff7452
I spend quite a lot of time on this. So for those who will find this issue.
If you have rails and setted up docker-compose with selenium server, but want to keep also working local environment with automatically managed webdrivers. Just add conditional require for webdrivers
:
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara'
# A browser automation framework and ecosystem
gem 'selenium-webdriver'
# Keep your Selenium WebDrivers updated automatically
gem 'webdrivers', require: !ENV['SELENIUM_REMOTE_URL']
end
Simplified docker-compose:
version: '3'
services:
app:
build:
context: .
environment:
SELENIUM_REMOTE_URL: http://webdriver_chrome:4444/wd/hub
depends_on:
- db
- webdriver_chrome
command: bin/rails s -b 0.0.0.0 -p 3000
db:
# ...
webdriver_chrome:
image: selenium/standalone-chrome
Cheers!
@freaz thanks for sharing as we had the same issue. That was super helpful! ❤️
I am experiencing the same issue on Circle CI.
Webdrivers::BrowserNotFound:
Failed to find Chrome binary.
My configuration:
require 'capybara/rails'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
require 'selenium-webdriver'
require 'webdrivers/chromedriver'
Capybara.asset_host = 'http://localhost:3000'
CAPYBARA_WINDOW_SIZE = [1366, 768].freeze
Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("headless")
options.add_argument("window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}")
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options
)
end
Capybara.javascript_driver = :chrome
Capybara.ignore_hidden_elements = false
Capybara.save_path = "spec/screenshots"
Capybara::Screenshot.autosave_on_failure = false
# Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run
# From https://github.com/mattheworiordan/capybara-screenshot/issues/84#issuecomment-41219326
Capybara::Screenshot.register_driver(:chrome) do |driver, path|
driver.browser.save_screenshot(path)
end
So i figured out the problem. Chrome needs to be installed on circle ci. So the config.yml
for circleci has to be updated in order to use ruby version with browser support available here.
So the yml file looks like this now:
version: 2
jobs:
build:
working_directory: ~/project
docker:
# Browser support ruby versions
- image: circleci/ruby:2.5.1-node-browsers
environment:
PGHOST: localhost
PGUSER: user
RAILS_ENV: test
- image: postgres:9.5
environment:
POSTGRES_USER: project
POSTGRES_DB: project_test
POSTGRES_PASSWORD: ""
For anyone landing here still stuck despite @ahmad19's helpful message, this has changed again for newer Ruby versions (e.g. 2.7).
See "Browsers" at the bottom of https://circleci.com/developer/images/image/cimg/ruby
Summary
Since upgrading from Rails 6rc1 to Rails 6rc2, I get the error
Debug Info
Expected Behavior
No error thrown. I gather that the the relevant executable is not being downloaded, so I think that's the error, but to be honest I may need guidance to give a more informed bug report.
Actual Behavior
What is actually happening: Error message, stack trace, DEBUG log if applicable (set
Webdrivers.logger.level = :DEBUG
after you require webdrivers)When running tests I receive the error:
When rolling back to Rails 6 rc1, then there is no directory /home/rails_user/.webdrivers/ either.
Please let me know how if I can help by providing any other information.