I am setting up Cucumber tests in a Rails project. Everything works fine when I use the default driver; but, when I try to use the :selenium_chrome
driver, the browser tries to load example.com
instead of the local Rails server. Any idea what I'm missing?
My steps look like this:
Before do |scenario|
Capybara.current_driver = :selenium_chrome
end
When(/^I visit the posts page$/) do
visit posts_url
end
When I run the features, I can see that the rails server gets launched:
Using the default profile...
Feature: Posts
Capybara starting Puma...
* Version 3.12.0 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:62056
But, the Chrome window that pops up is attempting to access http://www.example.com/posts
instead of http://127.0.0.1:62056/posts
Am I missing a configuration step somewhere?
On a related note: If I want to run all my tests using Selenium, should I have to put the Capybara.current_driver
line in a Before
block? I tried just adding it to features/support/env.rb
, but it didn't seem to have any effect.
I have Chrome 73.0.3683.86 and Rails 5.2.2 running on MacOS 10.14.4.