I am having trouble getting chromedriver on Travis-CI working for my project knockout-secure-binding. I am trying to use WebdriverJS to automate testing with Chrome, at the leas
EDIT: As of October 2018, Travis CI is slowly moving away from containers (see official announcement). Therefore, one can omit sudo: false
, but the given ChromeDriver setup still works.
If you want to use a container-based environment (fast boot time but no you can also do it as follows (include sudo
),language
and so forth accordingly):
dist: trusty
sudo: false
addons:
chrome: stable
apt:
packages:
- chromium-chromedriver
before_script:
# include ChromeDriver in PATH
- ln --symbolic /usr/lib/chromium-browser/chromedriver "${HOME}/bin/chromedriver"
# start Chrome and listen on localhost
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
Afterwards, as you already mentioned, add --no-sandbox
to your Chrome options (taken from this gist):
var webdriver = require('selenium-webdriver');
var chromeOptions = {
'args': ['--no-sandbox']
};
var chromeCapabilities = webdriver.Capabilities.chrome();
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
This is due to an issue in Travis CI. However, if you need sudo
anyway or have a long-running build where a container-based environment makes only limited sense, you can also set sudo: true
and omit adding --no-sandbox
.
Additional resources: