Skip to content

Instantly share code, notes, and snippets.

@SergeyAvd
Created March 3, 2017 17:27
Show Gist options
  • Save SergeyAvd/e185291b52b915168ad981ba4dd14e48 to your computer and use it in GitHub Desktop.
Save SergeyAvd/e185291b52b915168ad981ba4dd14e48 to your computer and use it in GitHub Desktop.
Connect to an existing chromedriver on port 9515
const {Builder, By, until, Capabilities} = require('selenium-webdriver');
// Make sure `chromedriver --port=9515` was started before
var driver = new Builder()
.withCapabilities(Capabilities.chrome())
.usingServer('http://localhost:9515')
.build();
driver.get('http://www.google.com/ncr')
.then(_ => driver.findElement(By.name('q')).sendKeys('webdriver'))
.then(_ => driver.findElement(By.name('btnG')).click())
.then(_ => driver.wait(until.titleIs('webdriver - Google Search'), 1000))
.then(_ => driver.quit());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment