Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ChromeDriver on Travis CI
os: linux
node_js: '12'
sudo: required
env: DISPLAY=':99.0'
dist: trusty
addons:
apt:
update: true
sources:
- google-chrome
packages:
- dpkg
- google-chrome-stable
before_script:
- sh -e /etc/init.d/xvfb start
os: osx
node_js: '12'
sudo: required
env: HOMEBREW_CASK_OPTS='--appdir=/Applications'
before_install:
- brew update > /dev/null
- brew cask install google-chrome
language: node_js
matrix:
include:
- os: linux
node_js: '12'
sudo: required
env: DISPLAY=':99.0'
dist: trusty
addons:
apt:
update: true
sources:
- google-chrome
packages:
- dpkg
- google-chrome-stable
- os: osx
node_js: '12'
sudo: required
env: HOMEBREW_CASK_OPTS='--appdir=/Applications'
before_install:
- |
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew update > /dev/null
brew cask install google-chrome
fi
install:
- npm install
before_script:
- |
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
sh -e /etc/init.d/xvfb start
fi
script:
- npm test
{
"devDependencies": {
"chromedriver": "^76.0.1",
"selenium-webdriver": "^4.0.0-alpha.5"
}
}
const webdriver = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const chromedriver = require("chromedriver");
const until = webdriver.until;
const By = webdriver.By;
const options = new chrome.Options();
options.addArguments("no-sandbox");
const builder = new webdriver.Builder();
builder.forBrowser("chrome");
builder.setChromeOptions(options);
const driver = builder.build();
(async () => {
await driver.manage().setTimeouts({ implicit: 30000 });
await driver.get("https://tweetdeck.twitter.com");
await driver.wait(until.titleIs("TweetDeck"));
const login = await driver.findElement(By.css("section.form-login a.Button"));
await login.click();
})();
@richtr

This comment has been minimized.

Copy link

richtr commented Sep 11, 2019

I received the following dpkg error on trying to install google-chrome-stable via addons as shown above:

dpkg-deb: error: archive '/var/cache/apt/archives/google-chrome-stable_77.0.3865.75-1_amd64.deb' has premature member 'control.tar.xz' before 'control.tar.gz', giving up
dpkg: error processing archive /var/cache/apt/archives/google-chrome-stable_77.0.3865.75-1_amd64.deb (--unpack):
 subprocess dpkg-deb --control returned error exit status 2

Adding the following to the .travis.linux.yml file fixed it so it now works again (upgrade dpkg before installing google-chrome-stable):

addons:
  apt:
+   update: true
    sources:
     - google-chrome
    packages:
+    - dpkg
     - google-chrome-stable
@dougjohnston

This comment has been minimized.

Copy link

dougjohnston commented Sep 13, 2019

@richtr and @chitoku-k I ran into the same dpkg error and can confirm that your fix works great. Thanks SO MUCH for posting this! I had been relying on Travis's dated version of Chrome plus the latest version of chromedriver and was running into incompatibility issues every few months. Seems like using apt with this fix gets my Chrome and chromedriver versions synced up and on an evergreen path now. Thanks again!

@chitoku-k

This comment has been minimized.

Copy link
Owner Author

chitoku-k commented Sep 15, 2019

@richtr I appreciate your suggestions that pointed out how to fix that issue. Your fix successfully revived this config and I ascertained that the dpkg is the root cause that prevented from this script working. And also thanks @dougjohnston for another successful reporting as well. The fix and the sample for TweetDeck has also been updated!

@peter279k

This comment has been minimized.

Copy link

peter279k commented Jan 1, 2020

I've created the repository and integrate Travis CI build service for these gist snippets.

Please feel free to use and refer :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.