Gitlab CI will not recognize chromedriver as being on PATH (even though it is)

540 Views Asked by At

We are using selenium 3.141.0 with splinter 0.17.0 to run automation tests in Gitlab CI (linux). For a long time this was working, and then an internal update created issues that only appeared when running tests with remote browsers. To work around this we attempted to run a local browser instead ie. without selenium hub, headless, and by passing the directory of the driver location directly.

self.splinter = Browser(
    driver_name="chrome",
    headless=True,
    **executable_path,
    desired_capabilities={
        'browserName': browser_name,
        'version': browser_version,
        'platform': platform_name,
        'acceptSslCerts': True,
        },
    options=options,
)

The issue is that no matter where I put the driver, when this line is run in the CI job it fails.

'chromedriver' executable needs to be in PATH.

I have been on this for a long time and have tried many things. In the same script section of the ci job, just before running selenium I set the path like this.

- export PATH="/drivers/linux:$PATH"

I then echo PATH and can see that the correct directory is listed. I also print the PATH in the python file right before creating the browser via print(os.environ['PATH']) and it matches and has the directory of the drivers. I am sure the drivers exist because I also pass the directory to os.path.exists() which returns true. I have done this for multiple drivers in many different locations including the root directory of the project, /usr/local/lib, /usr/local/lib/python3.8/site-packages, and even the binary location given when using chromedriver-py. All of these locations are on path and they all work on my machine when I try to run an OSX chromedriver in the same location, yet they all fail in the CI trying to run the linux driver version with the same PATH error.

In the same script section I also make sure the permissions are acceptable.

- chmod 777 .../linux/chromedriver

I can use python to assert that the permissions are correct so I don't think this is the issue.

The only cause for this I can imagine at this point is that the error message is wrong.

Any ideas of things to try would be very appreciated.

EDIT: Here is the output of the CI job. Here I'm desperately adding every driver location and parent of that driver to path. Then I echo PATH and can see that they are there. PATH is also printed from python while the behave line runs. It also prints the output of which chromedriver which returns one of the driver locations.

export PATH="/builds/MeTRA/quality-assurance/metra-tests/drivers/linux:$PATH"
$ export PATH="/builds/MeTRA/quality-assurance/metra-tests:$PATH"
$ export PATH="/builds/MeTRA/quality-assurance:$PATH"
$ export PATH="/builds/MeTRA:$PATH"
$ export PATH="/builds:$PATH"
$ export PATH="/drivers/linux:$PATH"
$ export PATH="/usr/local/lib/python3.8/site-packages/chromedriver_py:$PATH"
$ export PATH="/usr/local/lib/python3.8/site-packages:$PATH"
$ export PATH="/usr/local/lib/python3.8:$PATH"
$ export PATH="/usr/local/lib:$PATH"
$ export PATH="/usr/local:$PATH"
$ export PATH="/usr:$PATH"
$ export PATH="/app:$PATH"
$ export PATH="/app/drivers/linux:$PATH"
$ echo $PATH
/app/drivers/linux:/app:/usr:/usr/local:/usr/local/lib:/usr/local/lib/python3.8:/usr/local/lib/python3.8/site-packages:/usr/local/lib/python3.8/site-packages/chromedriver_py:/drivers/linux:/builds:/builds/MeTRA:/builds/MeTRA/quality-assurance:/builds/MeTRA/quality-assurance/metra-tests:/builds/MeTRA/quality-assurance/metra-tests/drivers/linux:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$ chmod 777 /usr/local/lib/python3.8/site-packages/chromedriver_py/chromedriver_linux64
$ chmod 777 /builds/MeTRA/quality-assurance/metra-tests/drivers/linux/chromedriver
$ chmod 777 /builds/MeTRA/quality-assurance/metra-tests/chromedriver
$ behave -D ci -t ~@expected_failure -t ~@skip-on-chrome -e "scheduled" -n "User can delete a background image"

PATH:
/app/drivers/linux:/app:/usr:/usr/local:/usr/local/lib:/usr/local/lib/python3.8:/usr/local/lib/python3.8/site-packages:/usr/local/lib/python3.8/site-packages/chromedriver_py:/drivers/linux:/builds:/builds/MeTRA:/builds/MeTRA/quality-assurance:/builds/MeTRA/quality-assurance/metra-tests:/builds/MeTRA/quality-assurance/metra-tests/drivers/linux:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/app/drivers/linux/chromedriver

exists:  True
isfile:  True
File at this dir did not execute:
    /app/drivers/linux/chromedriver
    Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
'which chromedriver' returned: /app/drivers/linux/chromedriver

...same output for the others ones
0

There are 0 best solutions below