browser-testing

puppeteer: wait N seconds before continuing next line

房东的猫 提交于 2019-11-27 17:10:11
问题 in puppeteer I would like to wait a defined time before going to the next line of code. I've tried to put a setTimeout in an evaluate function but it seems to be simply ignored console.log('before waiting'); await page.evaluate(async() => { setTimeout(function(){ console.log('waiting'); }, 4000) }); console.log('after waiting'); This code don't wait and just write before waiting and after waiting Do you know how to do this? 回答1: You can use a little promise function, function delay(time) {