Last active
July 4, 2020 11:27
-
-
Save sergtimosh/1bf5d33a0d3eb929ffbca2bc8d5c8076 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//Assertions | |
async isElementVisible(css, timeout = 50) { | |
let visibility = true | |
await page | |
.waitForSelector(css, { visible: true, timeout: timeout }) | |
.catch(() => { | |
visibility = false; | |
}) | |
return visibility | |
}, | |
async isElementDisplayedByClass(css, timeout = 50) { | |
let visibility = true | |
await page | |
.waitForSelector(css + '.displayNone', { timeout: timeout }) | |
.catch(() => { | |
visibility = false; | |
}) | |
return visibility | |
}, | |
async isElementVisibleByWidth(css, timeout = 2000) { | |
let visible = true | |
await page.waitFor(css => | |
[...(document.querySelectorAll(css))] | |
.filter(el => el.offsetHeight !== 0) | |
.length !== 0 | |
, { timeout: timeout }, css) | |
.catch(() => { | |
visible = false | |
}) | |
return visible | |
}, | |
async isElementPresent(selector, timeout = 2000) { | |
let isPresent = true | |
await page.waitForSelector(selector, { timeout: timeout }) | |
.catch(() => | |
isPresent = false | |
) | |
console.log(`element is present - ${isPresent}`) | |
return isPresent | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment