run the test suite with Firefox - requires geckodriver to be installed. Then I tested it by visiting Google: describe "GET Google homepage", :type => :feature do it 'welcomes the user to Google' do visit(' ') expect(page.title).to have_content("Google") puts " cool, Google's title is 'Google' " end endįinally, I started testing my app, by visiting it at the URLs where I could expect to find it, since I had my backend and frontend servers running: describe "GET '/' - homepage title", :type => :feature do it 'welcomes the user to Word Nerds' do visit(' expect(page.title).to have_content("Word Nerds") puts 'the homepage title is Word Nerds' end end describe "GET '/' - homepage", :type => :feature do it 'welcomes the user to Word Nerds' do visit(' expect(page).to have_content("Word Nerds") puts 'cool, the homepage has words on it' end end describe "GET '/login", :type => :feature do it 'shows a login form' do visit(' expect(page).to have_content("Login") puts 'cool, the login form page says Login' end end Success If you and/or your company find value in Capybara and would like to contribute. I tested this by first visiting my API: describe "GET '/users' - from API", :type => :feature do it 'checks the first user in the database' do visit(' expect(page).to have_content("bob") puts 'cool, bob is in the house!' end end
#Capybara unable to find mozilla geckodriver download#
Finally I realized I need to visit the actual URL. Please download the server from and place it somewhere on your PATH. That route would probably work if my whole app were a Rails app, but my frontend was build with React. This issue can be worked around by setting the TMPDIR environment variable to a location that both Firefox and geckodriver have read/write access to e.g. You need to rename the binary file to wires (the. geckodriver uses the temporary directory to store Firefox profiles created during the run. Even though the project has been renamed to GeckoDriver, many of the selenium clients look for the old name.
I had some trouble with the Capybara visit method, because I thought I’d be able to visit('/') to visit my homepage, but that kept giving me errors. to access the system temporary directory. Please download the server from and place it somewhere on your PATH. Within my spec directory, I created a features folder, and within that I created a file, home_spec.rb, so named to test my app’s homepage. Selenium::WebDriver::Error::WebDriverError: Unable to find Mozilla geckodriver. Within that folder, I created a file, home_spec.rb, that looks like this: require 'spec_helper' class Home include Capybara::DSL def visit_homepage visit('/') end end feature "Visit homepage" do let(:home) ) end Capybara.javascript_driver = :poltergeist fault_driver = :poltergeist
I’m using RSpec, so I added a folder to spec, spec/features Then add this line to your test helper file, AKA spec_helper.rb: require 'capybara/rails' 2. The following are the list of steps to download gecko driver. Setupįirst, add this line to your Gemfile and run bundle install: gem 'capybara' However when I try to run some specs I get the following error: Selenium::WebDriver::Error::WebDriverError: Unable to find Mozilla geckodriver.Capybara chillin with an alligator 1. Options = Selenium::WebDriver::Chrome::Options.new(Īrgs: %wĬfault_driver = :chrome_headlessĬonfig.infer_spec_type_from_file_location! I have an Rspec setup with a spec support file for Capybara that looks like this: require 'capybara/rails'Ĭapybara.register_driver(:chrome_headless) do |app|