1

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:
- iamsmj@gmail.com

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.
Emjey
  • 2,038
  • 3
  • 18
  • 33
  • Did you try setting is explicitly in your script? `Selenium::WebDriver::Chrome::Service.executable_path = '/usr/bin/chromedriver'` – Raphael Feb 13 '17 at 18:30
  • @Raphael Nope! Didnt! Can you tell me where do I have to mention this code? Is it in `before_script`? – Emjey Feb 13 '17 at 18:44
  • @Raphael : This is the raw log https://api.travis-ci.org/jobs/201230860/log.txt?deansi=true – Emjey Feb 13 '17 at 18:57
  • Could you fix the indentation in the `before_script` stage and run a build again? – joepd Feb 14 '17 at 09:46
  • Okay! @joepd : There is some progress now. I have updated my question. Please take a look – Emjey Feb 14 '17 at 11:01
  • This is the raw log, https://api.travis-ci.org/jobs/201469568/log.txt?deansi=true – Emjey Feb 14 '17 at 11:09
  • Somehow cucumber cannot read the files it needs to read. I see some indentation errors over there as well. Do the tests run on your local machine? What if you make a clone of your repository to a new, temporary directory? – joepd Feb 14 '17 at 11:17
  • @joepd : Yes the tests run in the local machine. I just erased the old directory and made a new one, and it runs. – Emjey Feb 14 '17 at 13:36
  • By saying cucumber files, what do u mean? Are u talking about the `feature` file? – Emjey Feb 14 '17 at 13:37
  • I tried pushing a feature file to see if travis wud run it. And Now i get this error. It looks like, the `chromedriver` access issue? https://api.travis-ci.org/jobs/201526250/log.txt?deansi=true – Emjey Feb 14 '17 at 14:38
  • Finally, I could pass the chromedriver error, but now I think, my tests arent launching there . PFB the log file https://api.travis-ci.org/jobs/201587885/log.txt?deansi=true – Emjey Feb 14 '17 at 17:32

2 Answers2

1

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:
- iamsmj@gmail.com
Emjey
  • 2,038
  • 3
  • 18
  • 33
0

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.

mohnstrudel
  • 639
  • 8
  • 22