Directly to the problem that I noticed while creating puppeteer automata.
I check if element exists like this:
const check = async () => {
let state = null
await page.waitForSelector(els.configurationBtn)
.then(res => res ? state = true : state = false)
.catch(() => { state = false })
enter code here
return state
}
But it is not a smooth way to prevent stopping the program when page.waitForSelector
throws an error.
My question is How can I wait for the element (check if exist) and return Boolean - true
if the element exists and false if the element doesn't exist or when page.waitForSelector
throws a timeout error.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…