Greshma Shaji
Greshma Shaji

Reputation: 15

Why I got the Timeout error when using Puppeteer?

What should I do when I get a timeout error for async tests and hooks?

enter image description here

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();
       
    })

})

Upvotes: 1

Views: 1483

Answers (1)

mpu
mpu

Reputation: 400

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:

await page.goto('https://www.google.com', {waitUntil: 'load', timeout: 10000});

Upvotes: 1

Related Questions