Skip to content

Instantly share code, notes, and snippets.

@mjul
Created January 10, 2018 08:22
Show Gist options
  • Save mjul/49d7d2a50105baaf69c268dd51bb062b to your computer and use it in GitHub Desktop.
Save mjul/49d7d2a50105baaf69c268dd51bb062b to your computer and use it in GitHub Desktop.
Selenium Javascript web-driver API with promises
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until,
logging = webdriver.logging;
// Selenium's promise module provides logging to report every instance of unsynchronized code running through the promise manager
logging.installConsoleHandler();
logging.getLogger('promise.ControlFlow').setLevel(logging.Level.ALL);
new webdriver.Builder()
.forBrowser('chrome')
.build()
.then(driver => createInitialState(config, driver))
.then(state => state.transitions.openStartPage())
.then(state => maximizeWindow(state))
.then(state => takeScreenshot(state))
.then(state => state.transitions.login())
.then(state => takeScreenshot(state))
.then(state => state.driver.quit());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment