Capybara Unable to find Mozilla geckodriver


#1

I have a Rails 5.0.2 app and I’m using rspec and capybara for testing.
I’m using firefox for my javascript enabled feature specs.
On my local machine these are working ok.
When I push to master and CircleCI runs my specs I get the following error:

Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.

I’m using ruby 2.4, capybra 2.12.1.

I had assumed this would be a fairly standard setup but there doesn’t seem to be any info about this specific error on CircleCI.

Any suggestions gratefully received!


#2

So I fixed this by downgrading my firefox to version 44 and setting my selenium-webdriver gem to 2.53.1

A few of my specs had to be adjusted to work with these different versions but CircleCi seems to be able to run them now which is nice.


#3

I tried and failed to get geckodriver setup by manually attempting to installing it and still failed. If anyone has managed to get this to work, please chime in.


#4

Possibly having path issues. Try this code snippet:

dependencies:
  post:
    - mkdir drivers
    - wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz && tar -zxvf geckodriver-v0.11.1-linux64.tar.gz:
        pwd: drivers

Adjust version as needed :slight_smile:


#5

I tried this out, but I’m still getting the same error:

Selenium::WebDriver::Error::WebDriverError:
Unable to find Mozilla geckodriver. Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH.

Does this code snippet actually place the drivers directory on the containers path, or just unzip the tar to that directory?

I’m using the latest version of selenium-webdriver (3.3.something) and trying to use geckodriver 0.15.

Are these versions supported? If not I’m not sure how I can manage two sets of selenium/firefox for circleci and for my local dev environments.


#6

Hi there, could you answer Zacharw;s question? I’m having the same issue and would love to know! :slight_smile: thanks!


#7

Hey! i was able to fix this by adding the path to my PATH:

machine:
  environment:
    PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/drivers"

#8

I ended up fixing it by setting up a chrome selenium driver instead of firefox - that worked on circleci out of the box.

In spec_helper.rb:

Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, :browser => :chrome)
end

Capybara.javascript_driver = :chrome

You will have to brew install chromedriver on your local machine.


#9

@zacharyw you didn’t have to add a Docker image or anything? I tried adding that with no luck. Tried pretty much everything I could find on here with no luck.

version: 2
jobs:
  build:
    docker:
      - image: circleci/ruby:2.3.4
      - image: selenium/standalone-chrome:latest
    working_directory: ~/repo
    steps:
      - checkout
      - run: echo "Running from .circleci/config.yml"
      - run: echo $CC_TEST_REPORTER_ID
      - run: ruby -v
      - run: gem install bundler -v 1.15.4
      - run: bundler -v
      - restore_cache:
          key: rails-{{ arch }}-{{ checksum "Gemfile.lock" }}
      - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
      - save_cache:
          key: rails-{{ arch }}-{{ checksum "Gemfile.lock" }}
          paths:
            - vendor/bundle
      - run:
          name: Install latest version of ChromeDriver Sample
          command: |
            sudo wget https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip
            sudo unzip chromedriver_linux64.zip
            sudo rm chromedriver_linux64.zip
            sudo mv chromedriver /usr/bin/
            sudo chmod 777 /usr/bin/chromedriver
            sudo apt-get install libxi6 libgconf-2-4
            sudo apt-get -y install xvfb gtk2-engines-pixbuf
            sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
            sudo apt-get install xvfb
            sudo apt-get -y install imagemagick x11-apps
      - run: rubocop
      - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
      - run: chmod +x ./cc-test-reporter
      - run: ./cc-test-reporter before-build
      - run: bundle exec rspec spec
      - run: ./cc-test-reporter after-build --exit-code $? || true


#10