Emjey
Emjey

Reputation: 2063

Travis: Unable to find chromedriver

I am trying to integrate travis to my cucumber tests using watir. However, Now, I seem to be stuck in the last problem with chromedriver. I get the error

Unable to find chromedriver. Please download the server from    http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at   https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.

(Selenium::WebDriver::Error::WebDriverError)

I fixed this thing in my local windows machine by adding chromedriver in lib folder of ruby and adding path to system32, webem

I am not sure on how to do about this in Travis. Can someone help me?

My .travis.yml file looks like this

sudo: required
language: ruby
cache: bundler

rvm: 2.2

 before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
script: bundle exec cucumber

branches:
only:
- master

notifications:
email:
- [email protected]

I have added the below code to the existing .yml

addons: apt: packages: - chromium-browser - chromium-chromedriver

rvm: 2.2

before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
    - wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
      - unzip chromedriver_linux64.zip
      - sudo chmod u+x chromedriver
      - sudo mv chromedriver /usr/bin/
      - export CHROME_BIN=chromium-browser
      - "export DISPLAY=:99.0"
      - "sh -e /etc/init.d/xvfb start"
      - sleep 3
      - ./travis_before_install

The error i get now is

    --2017-02-13 18:04:46--  http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
    Resolving chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)... 64.233.191.128, 2607:f8b0:4001:c0c::80
    Connecting to chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)|64.233.191.128|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2692616 (2.6M) [application/zip]
    Saving to: `chromedriver_linux64.zip'
     0% [                                       ] 0           --.-K/s                100%[======================================>] 2,692,616   --.-K/s   in 0.009s  



    wget: unable to resolve host address `.'
    FINISHED --2017-02-13 18:04:48--
    Total wall clock time: 1.5s
    Downloaded: 1 files, 2.6M in 0.009s (281 MB/s)
    The command "wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip - unzip chromedriver_linux64.zip - sudo chmod u+x chromedriver - sudo mv chromedriver /usr/bin/ - export CHROME_BIN=chromium-browser - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" - sleep 3 - ./travis_before_install" failed and exited with 4 during .
    Your build has been stopped.


Also, Could someone please let me know, why travis wouldnt run this?

`The command "bundle exec cucumber" exited with 2.`


UPDATE: I updated the file fixing the indentation in the `before_script` . The latest error i get is 

    0.08s$ unzip chromedriver_linux64.zip
   Archive:  chromedriver_linux64.zip
  inflating: chromedriver            
   before_script.10
   0.01s$ sudo chmod u+x chromedriver
   before_script.11
   0.01s$ sudo mv chromedriver /usr/bin/
   before_script.12
   0.00s$ export CHROME_BIN=chromium-browser
   before_script.13
   0.00s$ export DISPLAY=:99.0
   before_script.14
   0.01s$ sh -e /etc/init.d/xvfb start
   Starting virtual X frame buffer: Xvfb.
   before_script.15
   3.01s$ sleep 3
   2.55s$ bundle exec cucumber
   end of file reached (EOFError)
   The command "bundle exec cucumber" exited with 2.
Done. Your build exited with 1. 


     **Update:** I tried fixing up the identation errors in the script as. The new error i get is 

     0% [                                       ] 0           --.-K/s                  100%[======================================>] 2,692,616   --.-K/s   in 0.01s   
   2017-02-14 11:00:45 (173 MB/s) - ‘chromedriver_linux64.zip’ saved    [2692616/2692616]
    before_script.9
   0.08s$ unzip chromedriver_linux64.zip
   Archive:  chromedriver_linux64.zip
   inflating: chromedriver            
    before_script.10
   0.01s$ sudo chmod u+x chromedriver
   before_script.11
   0.01s$ sudo mv chromedriver /usr/bin/
   before_script.12
   0.00s$ export CHROME_BIN=chromium-browser
   before_script.13
   0.00s$ export DISPLAY=:99.0
   before_script.14
   0.01s$ sh -e /etc/init.d/xvfb start
   Starting virtual X frame buffer: Xvfb.
   before_script.15
   3.01s$ sleep 3
   2.55s$ bundle exec cucumber
   **end of file reached (EOFError)**
   The command "bundle exec cucumber" exited with 2.
    Done. Your build exited with 1.

Upvotes: 1

Views: 2471

Answers (2)

mohnstrudel
mohnstrudel

Reputation: 649

I tried your solution for myself, since I encountered the same error, but it didn't work out. After combining the docs and this SO answer I ended up with this setup, which works:

dist: trusty

language: ruby

sudo: required

before_install:
  - gem install bundler
  - "rm ${BUNDLE_GEMFILE}.lock"
  - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &

cache: bundler

rvm:
 - 2.4.0

env:
 - DB=pgsql

services:
 - postgresql

test:
  adapter: postgresql
  database: app_test

addons:
  chrome: stable

# uncomment and edit the following line if your project needs to run something other than `rake`:
# script: 
# - bundle exec rspec spec

before_script:
 - cp config/database.yml.travis config/database.yml
 - psql -c 'create database app_test;' -U postgres
 - bundle update
 - bundle exec rake db:test:prepare
 - export DISPLAY=:99.0
 - sh -e /etc/init.d/xvfb start
 - sleep 3

deploy:
  provider: heroku
  api_key:
    secure: "api_ley"
  app: awesome-development-app

notifications:
  slack: app:key

Important steps are: google-chrome-stable in before_install, addons - chrome - stable and DISPLAY value.

Maybe it helps someone.

Upvotes: 0

Emjey
Emjey

Reputation: 2063

Finally, Was able to get the travis run my cucumber tests.

Changes I did

  1. Provided sudo for permission change that used to displayed Not permitted
  2. Downgraded Chromedriver version from 2.7 to 2.27

These fixed it

The current .travis.yml file looks like this

sudo: required
language: ruby

dist: trusty

addons:
  apt:
    sources:
       - google-chrome
    packages:
    - google-chrome-stable


 script: bundle exec cucumber


 before_script:
    - bundle install
    - gem install watir
    - gem install colorize
    - gem install rspec
    - gem install cucumber
    - gem install rake
    - gem install chromium
    - wget http://chromedriver.storage.googleapis.com/2.27/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    - sudo apt-get install libnss3
    - sudo apt-get --only-upgrade install google-chrome-stable
    - sudo cp chromedriver /usr/local/bin/.
    - sudo chmod +x /usr/local/bin/chromedriver
    - export DISPLAY=:99.0
    - sh -e /etc/init.d/xvfb start
    - sleep 3


branches:
 only:
  - master

notifications:
 email:
- [email protected]

Upvotes: 1

Related Questions