在 puppeteer 中,我想在执行下一行代码之前等待一段定义的时间。我尝试在 evaluate 函数中使用
setTimeout
,但似乎被简单地忽略了。console.log('before waiting');
await page.evaluate(async() => {
setTimeout(function(){
console.log('waiting');
}, 4000)
});
console.log('after waiting');
这段代码不等待,直接在等待之前和等待之后写入。你知道如何做到这一点吗?