propre_poli
propre_poli

Reputation: 55

How to make Puppeteer's waitFor work? It blocks execution in current form

async function clickElement(page){
    await page.evaluate(async () => {
        let elements = document.getElementsByClassName('bzsjyuwj ni8dbmo4 stjgntxs ltmttdrg gjzvkazv');
        let element = elements[0];
        await element.click();
        await page.waitFor(111);
        alert("Program does not reach here.");
    });   
}

I am trying to implement a delay while working with puppeteer. However, it seems that code execution does not reach past the waitFor function. How could this be?

Upvotes: 1

Views: 1331

Answers (1)

propre_poli
propre_poli

Reputation: 41

OP here, the following works:

await new Promise(function(resolve) {setTimeout(resolve, 2000)});

Upvotes: 4

Related Questions