Reputation: 12663
I'm trying to configure a Rails app for testing on CircleCI 2.0 (it was working perfectly on v1.0).
I've set up a config file with the following Docker images (my first time using Docker, so unsure whether this is the correct):
build:
docker:
- image: circleci/ruby:2.4-node
environment:
SELENIUM_DRIVER_URL: http://localhost:4444/wd/hub
- image: circleci/postgres:10.2
environment:
POSTGRES_USER: user
POSTGRES_DB: datatbase
POSTGRES_PASSWORD: ""
- image: selenium/standalone-chrome:3.5.3
Everything is working, all tests are passing, except one!
Failure/Error: attach_file 'file', File.join(Rails.root, 'spec', 'support', 'images', 'test_image.jpg'), visible: false
Selenium::WebDriver::Error::ExpectedError:
invalid argument: File not found : /home/circleci/project/spec/support/images/test_image.jpg
test_image.jpg
does exist. It is used by other non-JS specs that are all successfully passing.
This failing spec is the only one that tests javascript, and hence is being run via selenium/ chrome.
From the test output, it seems that selenium is looking in home/circleci/project
, rather than the Rails root folder.
How do I configure things to ensure that this spec looks in the correct root directory for this file?
Upvotes: 2
Views: 532
Reputation: 343
I'm elaborating a bit more the solution proposed by the OP, as I needed to add this configuration to my circleci config.yml file in order to have Capybara work correctly with Selenium:
- run:
name: Download Selenium
command: |
curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
- run:
name: Start Selenium
command: |
java -jar selenium-server-standalone-3.5.3.jar -log selenium.log
background: true
I'm not adding a comment to the OP solution as code would not be properly shown.
Upvotes: 1
Reputation: 12663
It took me a long time to get to the bottom of this. I'm fairly new to Docker, and in many places the CircleCI documentation left me feeling in the dark.
In case this is is useful for anyone who encounters this issue, I dropped image: selenium/standalone-chrome:3.5.3
from my config file, and instead used a Ruby image containing everything circleci/ruby:2.4-node-bowsers
.
build:
docker:
- image: circleci/ruby:2.4-node-bowsers
environment:
RAILS_ENV: test
- image: circleci/postgres:10.2
environment:
POSTGRES_USER: user
POSTGRES_DB: datatbase
POSTGRES_PASSWORD: ""
Problem solved!
Upvotes: 1