So this is the code
if (
(await page.waitForSelector("#btn")) !==
null
) {
await page.click("#btn")
} else {
await page.waitForSelector("#element")
}
}
And it didn't want to execute else part at all. So if function should work when modal window displayed, and it works but if modal window didnt displayed else function didnt executed. Any ideas will be appreciated!
The second way I use it was
if (
await page.waitForSelector("#btn", {
visible: true,
})
) {
await page.click("#btn")
} else {
await page.waitForSelector("#element", { visible: true })
}
}
But result is the same? else function didnt executed, test waiting if statement.