如何用木偶操纵者延迟这个评估
how to put a delay in this evaluate with puppeteer
我正试图通过 puppeteer 延迟此评估,但我尝试了所有方法但没有成功,例如:
await page.waitForTimeout(1000);
或与:
setTimeout(() => { }, 1000);
await page.evaluate(() => {
let elements = document.getElementsByClassName('button-text');
for (let element of elements) if (element.innerText == 'Add') element.click();
})
我希望它像这个例子一样在每次点击后出现,但它永远行不通:
await page.evaluate(() => {
let elements = document.getElementsByClassName('button-text');
for (let element of elements)
if (element.innerText == 'Add'){
await page.waitForTimeout(1000);
element.click();
}
})
您想在浏览器上下文之外执行此操作:
let elements = await page.$$eval('.button-text', els => els.filter(el => el.innerText === 'Add'))
for(let element of elements){
await page.waitForTimeout(1000)
await element.click()
}
我正试图通过 puppeteer 延迟此评估,但我尝试了所有方法但没有成功,例如:
await page.waitForTimeout(1000);
或与:
setTimeout(() => { }, 1000);
await page.evaluate(() => {
let elements = document.getElementsByClassName('button-text');
for (let element of elements) if (element.innerText == 'Add') element.click();
})
我希望它像这个例子一样在每次点击后出现,但它永远行不通:
await page.evaluate(() => {
let elements = document.getElementsByClassName('button-text');
for (let element of elements)
if (element.innerText == 'Add'){
await page.waitForTimeout(1000);
element.click();
}
})
您想在浏览器上下文之外执行此操作:
let elements = await page.$$eval('.button-text', els => els.filter(el => el.innerText === 'Add'))
for(let element of elements){
await page.waitForTimeout(1000)
await element.click()
}