Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chromedriver support? #272

Closed
zspencer opened this issue Sep 27, 2011 · 45 comments
Closed

Chromedriver support? #272

zspencer opened this issue Sep 27, 2011 · 45 comments

Comments

@zspencer
Copy link

Would be nice if we could have chromedriver and/or firefox for ui testing.

@steveklabnik
Copy link
Contributor

Firefox should be on there. Selenium should work.

@steveklabnik
Copy link
Contributor

@parndt
Copy link
Contributor

parndt commented Sep 27, 2011

You can also use capybara-webkit if that's good enough unless you need the whole Chrome browser?

@zspencer
Copy link
Author

Does that mean that I can also use jasmine-headless-webkit?

I didn't realize the worker nodes supported the qt library

@steveklabnik steveklabnik reopened this Dec 2, 2011
@steveklabnik
Copy link
Contributor

Actually, there are good reasons to use Chromedriver as well as that stuff. @svenfuchs @joshk, whatcha think? The main issue with this is that it's an executable that needs to be in $PATH, not something that can be handled with a before_script apt-get install.

@joshk
Copy link
Contributor

joshk commented Dec 2, 2011

Couldn't you install Chromedriver in a before_script and then add it to the 'PATH' in another?

But I am open to adding it to the standard box if someone writes up a cookbook?

@steveklabnik
Copy link
Contributor

I ended up trying something like this: steveklabnik/compatriot@22a7c5f

Gives me some sort of strange error, though: https://github.com/clnclarinet/compatriot/pull/3 Maybe it's related to using it with xvfb. Haven't fully investigated.

I'll re-close, since I discovered a workaround, at least.

@avernet
Copy link

avernet commented Mar 4, 2013

@joshk I am doing the following to install Chrome, so we can use ChromeDriver:

before_install:
  - wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
  - sudo apt-get update -qq
  - sudo dpkg -i ./google-chrome*.deb
  - sudo apt-get -f install

But this fails; it looks like Chrome needs some dependencies which it can't find:

Unpacking google-chrome-stable:i386 (from .../google-chrome-stable_current_i386.deb) ...
dpkg: dependency problems prevent configuration of google-chrome-stable:i386:
 google-chrome-stable:i386 depends on libasound2 (>> 1.0.22).
 google-chrome-stable:i386 depends on libatk1.0-0 (>= 1.29.3).
 google-chrome-stable:i386 depends on libbz2-1.0.
 google-chrome-stable:i386 depends on libc6 (>= 2.11).
 google-chrome-stable:i386 depends on libcairo2 (>= 1.6.0).
 google-chrome-stable:i386 depends on libcups2 (>= 1.4.0).
 google-chrome-stable:i386 depends on libdbus-1-3 (>= 1.2.14).
 google-chrome-stable:i386 depends on libexpat1 (>= 1.95.8).
 google-chrome-stable:i386 depends on libfontconfig1 (>= 2.8.0).
 google-chrome-stable:i386 depends on libfreetype6 (>= 2.3.9).
 google-chrome-stable:i386 depends on libgcc1 (>= 1:4.1.1).
 google-chrome-stable:i386 depends on libgconf2-4 (>= 2.27.0).
 google-chrome-stable:i386 depends on libgcrypt11 (>= 1.4.2).
 google-chrome-stable:i386 depends on libglib2.0-0 (>= 2.20.0).
 google-chrome-stable:i386 depends on libgtk2.0-0 (>= 2.18.0).
 google-chrome-stable:i386 depends on libnspr4-0d (>= 4.7.3-0ubuntu1~) | libnspr4 (>= 4.8.7-0ubuntu1).
 google-chrome-stable:i386 depends on libnss3-1d (>= 3.12.3).
 google-chrome-stable:i386 depends on libpango1.0-0 (>= 1.22.0).
 google-chrome-stable:i386 depends on libstdc++6 (>= 4.4.0).
 google-chrome-stable:i386 depends on libudev0 (>= 147).
 google-chrome-stable:i386 depends on libx11-6 (>= 0).
 google-chrome-stable:i386 depends on libxcomposite1 (>= 1:0.3-1).
 google-chrome-stable:i386 depends on libxext6 (>= 0).
 google-chrome-stable:i386 depends on libxfixes3 (>= 1:4.0.1).
 google-chrome-stable:i386 depends on libxrandr2 (>= 2:1.2.0).
 google-chrome-stable:i386 depends on libxrender1.
 google-chrome-stable:i386 depends on libxss1.
 google-chrome-stable:i386 depends on libcurl3.
 google-chrome-stable:i386 depends on xdg-utils (>= 1.0.2).
dpkg: error processing google-chrome-stable:i386 (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:
 google-chrome-stable:i386

The command "sudo dpkg -i ./google-chrome*.deb" failed and exited with 1 during before_install.

Do you see any workaround?

@avernet
Copy link

avernet commented Mar 4, 2013

OK, I got to install Chrome on Travis-CI with:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

See: .travis.yml

(Credits go to @evlist for getting this right.)

@joshk
Copy link
Contributor

joshk commented Mar 6, 2013

Awesome, thanks for figuring this out.

Would someone be interested in helping add this to our cookbooks?

https://github.com/travis-ci/travis-cookbooks/tree/master/ci_environment/chromium

On 5/03/2013, at 9:07 AM, Alessandro Vernet notifications@github.com wrote:

OK, I got to install Chrome on Travis-CI with:

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
See: .travis.yml

(Credits go to @evlist for getting this right.)


Reply to this email directly or view it on GitHub.

@ghost ghost assigned gildegoma Mar 6, 2013
@gildegoma
Copy link

@joshk I try to take this point until this week-end. I'll try to combine it with #938.

@joshk
Copy link
Contributor

joshk commented Mar 6, 2013

<3<3<3

On 7/03/2013, at 12:29 AM, Gilles Cornu notifications@github.com wrote:

@joshk I try to take this point until this week-end. I'll try to combine it with #938.


Reply to this email directly or view it on GitHub.

@avernet
Copy link

avernet commented Mar 6, 2013

@joshk The thing is that I wanted to install Chrome to be able to use ChromeDriver in automated tests, and even with Chrome properly installed, ChromeDriver is still hanging, and I still haven't figured that one out, and haven't seen anyone successfully running ChromeDriver on Travis-CI. So in a way, this issue on running ChromeDriver on Travis-CI is still "open".

@joshk
Copy link
Contributor

joshk commented Mar 7, 2013

Drat, that is annoying :/

I am not sure of the solution tbh. Does anyone have any ideas and thoughts about this?

On 7/03/2013, at 6:54 AM, Alessandro Vernet notifications@github.com wrote:

@joshk The thing is that I wanted to install Chrome to be able to use ChromeDriver in automated tests, and even with Chrome properly installed, ChromeDriver is still hanging, and I still haven't figured that one out, and haven't seen anyone successfully running ChromeDriver on Travis-CI. So in a way, this issue on running ChromeDriver on Travis-CI is still "open".


Reply to this email directly or view it on GitHub.

@gildegoma
Copy link

@avernet there is indeed a problem when installing google-chrome package from google apt repository, but the cause seems to be external and potentially impact any apt update command (because another apt repository is getting an error, as you can see here. We'll work on this problem, but you already can get it work with yes-forcing your apt commands as shown in gildegoma/travis-ci-inspector@c79c5bf

One more question to you @avernet: Could you also integrate with chromium-browser, which is actually preinstalled on travis boxes?

@gildegoma
Copy link

One more bad news: beside apt installation issue, it is currently not possible to execute chrome and chromium on new bluebox machines (Chrome cannot be executed in OpenVZ container). See #938.

@avernet
Copy link

avernet commented Mar 11, 2013

@gildegoma I managed to install Chrome on Travis-CI by adding these 4 commands to install Chrome to the .travis.yml in the before_install section. However, the thing is that the test hangs when ChromeDriver is being used. And to me, this doesn't seem to be a Travis-CI specific problem: I'm seem numerous people mention something similar when using the ChromeDriver on Linux/Xvfb, with no clear solution. For now, I resorted to using the Firefox driver.

@gildegoma
Copy link

@avernet unfortunately, Chrome (and Chromium) does not run in new Travis CI environment, based on OpenVZ technology. Tracking of this problem is in #938.
(great to hear that fallback to Firefox is "okay" for you, because it sounds hard to find a fix)

@avernet
Copy link

avernet commented Mar 11, 2013

@gildegoma Good to know; hopefully will can get fixed/implemented/supported soon. As a workaround, for open source projects who really want to test with Chrome, one option is to use Sauce, which will allow you to run your tests on any browser.

@gildegoma
Copy link

@avernet sure, Travis for server-side and SauceLabs for client-sides is an awesome combination! You should actually check (if not already done) upcoming improvement from @henrikhodne: travis-ci/travis-build#88 and be ready to update your .travis.yml.

On the other hand, #938 sounds very hard to be fixed (without a little help of Google...). 😒

@timp
Copy link

timp commented Feb 6, 2017

It would be good to have a way of using chromedriver, as per the issue title:
"Would be nice if we could have chromedriver and/or firefox for ui testing."

@reach2jeyan
Copy link

reach2jeyan commented Feb 13, 2017

Has anybody succeeded in debugging the issue?

I still get this 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)


Update: Now the error 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.

@LaiaPR
Copy link

LaiaPR commented Feb 13, 2017

Hi @reach2jeyan

it seems that new Linux version comes with Chrome pre-installed, you can see an example here:https://github.com/antonsamper/gulp-webpack-boilerplate/blob/master/.travis.yml

Hope it helps!

@reach2jeyan
Copy link

@LaiaPR Thanks! I ll try this out and let you know.

@reach2jeyan
Copy link

@LaiaPR I still 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)
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:59:in `binary_path'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:49:in `initialize'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/chrome/bridge.rb:35:in `new'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/chrome/bridge.rb:35:in `initialize'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/driver.rb:61:in `new'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/driver.rb:61:in `for'
/home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver.rb:82:in `for'
/home/travis/.rvm/gems/ruby-2.3.1/gems/watir-6.1.0/lib/watir/browser.rb:46:in `initialize'
/home/travis/build/divhegde/CucmbrEx/features/step_definitions/test_steps.rb:7:in `new'
/home/travis/build/divhegde/CucmbrEx/features/step_definitions/test_steps.rb:7:in `<top (required)>'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/home/travis/.rvm/gems/ruby-2.3.1/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/home/travis/.rvm/gems/ruby-2.3.1/bin/cucumber:23:in `load'
/home/travis/.rvm/gems/ruby-2.3.1/bin/cucumber:23:in `<main>'
/home/travis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
The command "bundle exec cucumber" exited with 2.
Done. Your build exited with 1.

My latest .travis.yml file looks like this. Kindly let me know if any changes are required. My project is built on cucucmber/gherkin with ruby using WATIR for browser testing.


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
        - export DISPLAY=:99.0
        - sh -e /etc/init.d/xvfb start
        - sleep 3
        

branches:
  only:
    - master

notifications:
  email:
    - iamsmj@gmail.com

@reach2jeyan
Copy link

reach2jeyan commented Feb 14, 2017

@LaiaPR I updated my .travis.yml to this now, and the new error is

0.90s$ gem install watir
Successfully installed watir-6.1.0
1 gem installed
before_script.3
0.45s$ gem install colorize
Fetching: colorize-0.8.1.gem (100%)Fetching: colorize-0.8.1.gem (100%)
Successfully installed colorize-0.8.1
1 gem installed
before_script.4
0.64s$ gem install rspec
Successfully installed rspec-3.5.0
1 gem installed
before_script.5
0.74s$ gem install cucumber
Successfully installed cucumber-2.4.0
1 gem installed
before_script.6
0.44s$ gem install rake
Successfully installed rake-12.0.0
1 gem installed
before_script.7
0.65s$ gem install chromium
Fetching: mustache-0.99.8.gem (100%)Fetching: mustache-0.99.8.gem (100%)
Successfully installed mustache-0.99.8
Fetching: chromium-0.1.0.gem (100%)Fetching: chromium-0.1.0.gem (100%)
Successfully installed chromium-0.1.0
2 gems installed
before_script.8
0.05s$ wget http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
--2017-02-14 11:00:45--  http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip
Resolving chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)... 74.125.129.128, 2607:f8b0:4001:c0b::80
Connecting to chromedriver.storage.googleapis.com (chromedriver.storage.googleapis.com)|74.125.129.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.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.

My .travis.yml looks like this now. Any ideas to get this fixed?


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.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
        

branches:
  only:
    - master

notifications:
  email:
    - iamsmj@gmail.com

PFB the raw log

https://api.travis-ci.org/jobs/201469568/log.txt?deansi=true

@reach2jeyan
Copy link

@LaiaPR I tried pushing a feature file and it seems like now the error is, it cannot access chromedriver ?

/home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:882:in `rescue in block in connect': Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515) (Errno::ECONNREFUSED)
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:879:in `block in connect'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:878:in `connect'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1476:in `begin_transport'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1433:in `transport_request'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1407:in `request'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:1156:in `get'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:116:in `block in stop_server'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:97:in `block in connect_to_server'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:853:in `start'
	from /home/travis/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/net/http.rb:584:in `start'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:93:in `connect_to_server'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:116:in `stop_server'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:79:in `stop'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/service.rb:69:in `block in start'
	from /home/travis/.rvm/gems/ruby-2.3.1/gems/selenium-webdriver-3.0.8/lib/selenium/webdriver/common/platform.rb:138:in `block in exit_hook'


The command "bundle exec cucumber" exited with 2.

Done. Your build exited with 1.

@reach2jeyan
Copy link

@LaiaPR Finally I could pass the chromedriver error only to see a new error, which wont build my tests

https://api.travis-ci.org/jobs/201587885/log.txt?deansi=true

My updated `.travis.yml`

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.7/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

@reach2jeyan
Copy link

@LaiaPR Finally! I am able to run it. Looks like the issue with chromedriver latest 2.7 version. I had to downgrade to 2.27

Thanks

@zeljkofilipin
Copy link

It is even simpler now.

sudo: required
dist: trusty
language: ruby
rvm:
 - 2.2
before_install:
 - sudo apt-get update
 - sudo apt-get install chromium-chromedriver
before_script:
  - "export PATH=$PATH:/usr/lib/chromium-browser/"
  - "export DISPLAY=:99.0"
  - "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

From: https://github.com/zeljkofilipin/mediawiki-selenium-rb/blob/master/.travis.yml
Job: https://travis-ci.org/zeljkofilipin/mediawiki-selenium-rb/

gruppjo added a commit to mwaylabs/generator-m-ionic-demo that referenced this issue Mar 15, 2017
gedex added a commit to woocommerce/wp-e2e-webdriver that referenced this issue Mar 16, 2017
gruppjo added a commit to mwaylabs/generator-m-ionic-demo that referenced this issue Mar 29, 2017
gruppjo added a commit to mwaylabs/generator-m-ionic-demo that referenced this issue Apr 12, 2017
* dev:
  1.12.0
  update deps
  yarn protractor
  side config-const
  new side module
  proper mini component
  bower updates
  #511: component sub-generator - test file and updated main.scss
  component-subgenerator: basic implementation
  Revert "break build"
  break build
  turn slack integration back on
  turn slack integration back on
  #511 component sub-generator - mini component example
  Revert "#487 travis, run protractor - give it another go travis-ci/travis-ci#272 (comment)"
  #487 travis, run protractor - give it another go travis-ci/travis-ci#272 (comment)
  #495 travis, mattermost - also add gitter webhook
  #495 travis - mattermost integration
@yeukhon
Copy link

yeukhon commented Jul 11, 2017

Okay.. I am confused how to support headless mode while using chromedriver WITHOUT XVFB. I am trying to run Chrome in headless mode.

Here is my travis.yml

sudo: required
dist: trusty
addons:
  apt:
    sources:
      - google-chrome
    packages:
      - google-chrome-stable

language: python
python:
  - "2.7"
before_install:
  - wget https://chromedriver.storage.googleapis.com/2.30/chromedriver_linux64.zip -O /tmp/chromedriver
  - chmod 777 /tmp/chromedriver
install:
  - python setup.py develop
env:
  - CHROME_DRIVER_PATH=/tmp/chromedriver
script: pytest

Here is my code in Python.

def setup_browser():
    """Returns a Chrome browser instance."""
    try:
        driver_path = os.environ["CHROME_DRIVER_PATH"]
    except KeyError as e:
        raise KeyError("Expect CHROME_DRIVER_PATH as environment variable")

    chrome_options = SOptions()
    chrome_options.add_argument("--headless")
    return webdriver.Chrome(driver_path, chrome_options=chrome_options)

This code works on local. Travis failed with:

_____________________________ test_non_exist_gmail _____________________________

non_exist_gmail = 'name.taken.yet.test.b60f5f51@gmail.com'

    def test_non_exist_gmail(non_exist_gmail):
>       result = check_account_exists(non_exist_gmail)

tests/test_check_gmail.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
name_taken_yet/check_gmail.py:41: in check_account_exists
    with open_browser(GMAIL_SIGNUP_URL, account_name) as browser:
/opt/python/2.7.13/lib/python2.7/contextlib.py:17: in __enter__
    return self.gen.next()
name_taken_yet/check_gmail.py:31: in open_browser
    browser = setup_browser()
name_taken_yet/check_gmail.py:27: in setup_browser
    return webdriver.Chrome(driver_path, chrome_options=chrome_options)
../../../virtualenv/python2.7.13/lib/python2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/chrome/webdriver.py:62: in __init__
    self.service.start()
../../../virtualenv/python2.7.13/lib/python2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/common/service.py:96: in start
    self.assert_process_still_running()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.chrome.service.Service object at 0x7f4bfb0ad090>

    def assert_process_still_running(self):
        return_code = self.process.poll()
        if return_code is not None:
            raise WebDriverException(
                'Service %s unexpectedly exited. Status code was: %s'
>               % (self.path, return_code)
            )
E           WebDriverException: Message: Service /tmp/chromedriver unexpectedly exited. Status code was: 1

../../../virtualenv/python2.7.13/lib/python2.7/site-packages/selenium-3.4.3-py2.7.egg/selenium/webdriver/common/service.py:109: WebDriverException
=========================== 3 failed in 3.16 seconds ===========================

My code: https://github.com/yeukhon/name-taken-yet/blob/8e57a1b386575a4d8f869491e6779adb0c71cb9e/name_taken_yet/check_gmail.py

I appreciate if someone can provide me a pointer.

@zeljkofilipin
Copy link

@yeukhon make sure chrome/chromium 59 is installed. I think this is the first version that supports headless mode.

@codingjoe
Copy link

@zeljkofilipin I guess it makes sense to have it available in the container builds too, fyi travis-ci/apt-package-safelist#4268

@Dantemss
Copy link

Dantemss commented May 16, 2018

@codingjoe I believe it has been whitelisted. The following worked for me for testing with Selenium in python, with sudo disabled (thanks to https://gist.github.com/thotmx/046b6fa582f0725dc783 for the idea):

addons:
  apt:
    packages:
      - chromium-chromedriver

before_script:
  - ln -s /usr/lib/chromium-browser/chromedriver ~/bin/chromedriver

The last part is needed because Selenium requires chromedriver in the PATH. Oh and you'll need to add the --headless, --no-sandbox and maybe --disable-dev-shm-usage to Selenium (ChromeDriver options) or whatever is booting up the chromedriver.

@codingjoe
Copy link

@Dantemss I just check it has not been whitelisted. Also I authored the PR that would whitelist it. Therefore I don't see how your config could actually work. Can you send me a link to a travis-ci build where the config you posted works?

nclopezo added a commit to chembl/GLaDOS that referenced this issue May 30, 2018
nclopezo added a commit to chembl/GLaDOS that referenced this issue May 30, 2018
@bryevdv
Copy link

bryevdv commented Jul 26, 2018

@codingjoe not sure if you are still looking for a link but here is a build that worked using @Dantemss config:

https://travis-ci.org/bokeh/bokeh/jobs/408648080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests