Last active
September 21, 2018 20:30
-
-
Save rhythnic/fba90298f4ddbf55422e2c605bf1d123 to your computer and use it in GitHub Desktop.
Helper functions for selenium-webdriver in Node.
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 { 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