Last active
September 2, 2022 06:33
-
-
Save chitoku-k/67068aa62aa3f077f5307ca9a822ce74 to your computer and use it in GitHub Desktop.
ChromeDriver on Travis CI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os: osx | |
node_js: '12' | |
sudo: required | |
env: HOMEBREW_CASK_OPTS='--appdir=/Applications' | |
before_install: | |
- brew update > /dev/null | |
- brew cask install google-chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"devDependencies": { | |
"chromedriver": "^76.0.1", | |
"selenium-webdriver": "^4.0.0-alpha.5" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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!
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
@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!