[英]Why I got the Timeout error when using Puppeteer?
What should I do when I get a timeout error for async tests and hooks?异步测试和钩子超时报错怎么办?
My code is:我的代码是:
const puppeteer = require('puppeteer');
describe('My First Puppeteer Test', () =>{
it('should launch the browser', async function(){
const browser = await puppeteer.launch({headless: false, slowMo: 500});
const page = await browser.newPage();
await page.goto('https://www.google.com');
await browser.close();
})
})
You can set a default timeout for all navigation operations using:您可以使用以下方法为所有导航操作设置默认超时:
const page = await browser.newPage();
page.setDefaultNavigationTimeout(10000);
Or you can also set the timeout for a specific page.goto
operation using:或者您也可以使用以下方法为特定的page.goto
操作设置超时:
await page.goto('https://www.google.com', {waitUntil: 'load', timeout: 10000});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.