Skip to content

Instantly share code, notes, and snippets.

@rhythnic
Last active September 21, 2018 20:30
Show Gist options
  • Save rhythnic/fba90298f4ddbf55422e2c605bf1d123 to your computer and use it in GitHub Desktop.
Save rhythnic/fba90298f4ddbf55422e2c605bf1d123 to your computer and use it in GitHub Desktop.
Helper functions for selenium-webdriver in Node.
const { Builder, until } = require('selenium-webdriver')
async function setupSeleniumDriver (config) {
let driver = await new Builder().forBrowser(config.BROWSER)
if (config.HUB_HOST) {
driver = driver.usingServer(`http://${config.HUB_HOST}:${config.HUB_PORT}/wd/hub`)
}
driver = driver.build()
await driver.manage().window().setPosition(0, 0)
await driver.manage().window().setSize(1280, 1024)
return driver
}
async function getLoadingElement(driver, selector, waitTime) {
const el = await driver.wait(until.elementLocated(selector), waitTime)
return driver.wait(until.elementIsVisible(el), waitTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment