Travis-CI: Test failed with 'geckodriver' executable needs to be in PATH

Hello,

I created a Plone add-on using plone.bobtemplate. I got the tests on Travis-CI running but the robot-test-example failed with:

Failure in test Scenario As a member I want to be able to log into the website (test_example.robot)
Traceback (most recent call last):
  File "/opt/python/3.7.1/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/opt/python/3.7.1/lib/python3.7/unittest/case.py", line 615, in run
    testMethod()
  File "/home/travis/buildout-cache/eggs/robotsuite-2.0.0-py3.7.egg/robotsuite/__init__.py", line 458, in runTest
    assert last_status == 'PASS', last_message
AssertionError: Setup failed:
WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

I use the following travis.yml file for configuration:

language: python
sudo: false
cache:
  pip: true
  directories:
  - eggs
  - downloads
python:
  - "2.7"
matrix:
  include:
    - python: "2.7"
      env: PLONE_VERSION=51
    - python: "2.7"
      env: PLONE_VERSION=52
    - python: "3.7"
      env: PLONE_VERSION=52
      dist: xenial
  sudo: true
  fast_finish: true
addons:
  apt:
    sources:
      - google-chrome
    packages:
      - google-chrome-stable
before_install:
  - virtualenv -p `which python` .
  - mkdir -p $HOME/buildout-cache/{eggs,downloads}
  - mkdir $HOME/.buildout
  - echo "[buildout]" > $HOME/.buildout/default.cfg
  - echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg
  - echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg
  - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt
#  - bin/buildout -N out:download-cache=downloads code-analysis:return-status-codes=True annotate
#  - bin/buildout -N buildout:download-cache=downloads code-analysis:return-status-codes=True
  - cp test_plone$PLONE_VERSION.cfg buildout.cfg

install:
  - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate
  - bin/buildout -N -t 3 code-analysis:return-status-codes=True

before_script:
  - wget "http://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip"
  - unzip chromedriver_linux64.zip
  - sudo mv chromedriver /usr/local/bin
  - 'export DISPLAY=:99.0'
  - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
  - sleep 3

script:
# Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout.
  - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis
  - bin/test --all

after_success:
  - bin/createcoverage --output-dir=parts/test/coverage
  - bin/pip install coverage
  - bin/python -m coverage.pickle2json
  - bin/pip install -q coveralls
  - coveralls

I tried also with another configuration [with firefox] without succes before (same message about geckodriver):

language: python
sudo: false
cache:
  pip: true
  directories:
  - eggs
  - downloads
python:
  - "2.7"
matrix:
  include:
    - python: "2.7"
      env: PLONE_VERSION=51
    - python: "2.7"
      env: PLONE_VERSION=52
    - python: "3.7"
      env: PLONE_VERSION=52
      dist: xenial
  sudo: true
  fast_finish: true
before_install:
  - virtualenv -p `which python` .
  - mkdir -p $HOME/buildout-cache/{eggs,downloads}
  - mkdir $HOME/.buildout
  - echo "[buildout]" > $HOME/.buildout/default.cfg
  - echo "download-cache = $HOME/buildout-cache/downloads" >> $HOME/.buildout/default.cfg
  - echo "eggs-directory = $HOME/buildout-cache/eggs" >> $HOME/.buildout/default.cfg
  - bin/pip install -r requirements.txt -c constraints_plone$PLONE_VERSION.txt
#  - bin/buildout -N out:download-cache=downloads code-analysis:return-status-codes=True annotate
#  - bin/buildout -N buildout:download-cache=downloads code-analysis:return-status-codes=True
  - cp test_plone$PLONE_VERSION.cfg buildout.cfg

install:
  - bin/buildout -N -t 3 code-analysis:return-status-codes=True annotate
  - bin/buildout -N -t 3 code-analysis:return-status-codes=True

before_script:
- 'export DISPLAY=:99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- sleep 3
- firefox -v

script:
# Run code-analysis, except on Python 3.6, which mysteriously fails to find zc.buildout.
  - python --version 2> /dev/stdout | grep 3.6 || bin/code-analysis
  - bin/test --all

after_success:
  - bin/createcoverage --output-dir=parts/test/coverage
  - bin/pip install coverage
  - bin/python -m coverage.pickle2json
  - bin/pip install -q coveralls
  - coveralls

I couldn't find a solution to fix this and get the test successful running.
Thanks for any hint in advance.
Andreas

Apparently, the testing framework (--> robotsuite) needs an external (typically OS level installed) helper program (--> geckodriver) and this is not available in your environment.

I would start by reading the robotsuite installation instructions to find out on which external components it depends and make those available.

I fixed the issue with a change in the travis.yml:


before_script:
  - wget "https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz"
  - tar xfz geckodriver-v0.24.0-linux64.tar.gz
  - sudo mv geckodriver /usr/local/bin
  - 'export DISPLAY=:99.0'
  - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
  - sleep 3

It seemed to be necessary to download the geckodriver and install it.

Thanks Andreas, I created a PR that fixes this in bobtemplates.plone: https://github.com/plone/bobtemplates.plone/pull/406

The TravisCI build system is by default based on Ubuntu trusty, xenial which is used by default for all our Python-builds.

Exception is Python 3.7, which can only be run the dist: xenial system, which has to be set explicitly.

On old Ubuntu trusty there is no geckodriver.

On Ubuntu xenial there is a firefox-geckodriver package available, which can be installed there.

addons:
  apt:
    packages:
      firefox-geckodriver

gecko-driver will be installed into /usr/bin/geckodriver.

Update: I just read, we could use xenial bionic by default, because it support all Python versions needed by us, see https://docs.travis-ci.com/user/reference/bionic/#python-support.

Plone Foundation Code of Conduct