Set timeout time works not in all cases in Pyppeteer

1.5k Views Asked by At

I set timeout time in Pyppeteer to 60 sec, but it doesn't work for all pages. Here is my code:

options = {'timeout': 60 * 1000}
response = await self.page.goto(url, options)

I try to load this URL with a timeout: http://www.google.com:81 But after 60 sec it doesn't raise timeout exception. After 4 minutes it raises net::ERR_TIMED_OUT How can I set timeout time for pages as I have?

2

There are 2 best solutions below

0
On

the options in pyppeteer need to be set as keyword arguments.

page.wait_for_selector('.someclass',timeout= 5000)
1
On

In Python, duration is calculated using seconds, not microseconds. That is why you have to:


options = {'timeout': 60}
response = await self.page.goto(url, options)