Skip to content

Instantly share code, notes, and snippets.

@juanpablocs
Last active February 21, 2018 22:44
Show Gist options
  • Select an option

  • Save juanpablocs/cc0807a00367c45c05d827455a7da529 to your computer and use it in GitHub Desktop.

Select an option

Save juanpablocs/cc0807a00367c45c05d827455a7da529 to your computer and use it in GitHub Desktop.
Install and ready selenium driver for node.js (required node 7+)

Install Chrome driver

wget -N https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip

sudo mv -f ~/chromedriver /usr/local/bin/chromedriver

Install selenium driver for node and ready test

npm init -y
npm i selenium-webdriver -D
touch index.js

Paste code and run

paste code in index.js

const {Builder, By, Key, until} = require('selenium-webdriver');

(async function example() {
  let driver = await new Builder().forBrowser('chrome').build();
  try {
    await driver.get('http://www.google.com/ncr');
    await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
    await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
  } finally {
    //await driver.quit();
  }
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment