2018-06-11 23:46:45 +02:00
|
|
|
const { until } = require('selenium-webdriver')
|
2018-05-25 03:17:26 +02:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
checkBrowserForConsoleErrors,
|
2018-06-06 04:21:55 +02:00
|
|
|
findElement,
|
|
|
|
findElements,
|
2018-05-25 03:17:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async function checkBrowserForConsoleErrors (driver) {
|
|
|
|
const ignoredLogTypes = ['WARNING']
|
|
|
|
const ignoredErrorMessages = [
|
|
|
|
// React throws error warnings on "dataset", but still sets the data-* properties correctly
|
|
|
|
'Warning: Unknown prop `dataset` on ',
|
|
|
|
// Third-party Favicon 404s show up as errors
|
|
|
|
'favicon.ico - Failed to load resource: the server responded with a status of 404 (Not Found)',
|
|
|
|
// React Development build - known issue blocked by test build sys
|
|
|
|
'Warning: It looks like you\'re using a minified copy of the development build of React.',
|
|
|
|
// Redux Development build - known issue blocked by test build sys
|
|
|
|
'This means that you are running a slower development build of Redux.',
|
|
|
|
]
|
|
|
|
const browserLogs = await driver.manage().logs().get('browser')
|
|
|
|
const errorEntries = browserLogs.filter(entry => !ignoredLogTypes.includes(entry.level.toString()))
|
|
|
|
const errorObjects = errorEntries.map(entry => entry.toJSON())
|
|
|
|
return errorObjects.filter(entry => !ignoredErrorMessages.some(message => entry.message.includes(message)))
|
|
|
|
}
|
|
|
|
|
2018-06-06 04:21:55 +02:00
|
|
|
async function findElement (driver, by, timeout = 10000) {
|
|
|
|
return driver.wait(until.elementLocated(by), timeout)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function findElements (driver, by, timeout = 10000) {
|
|
|
|
return driver.wait(until.elementsLocated(by), timeout)
|
|
|
|
}
|