Playwright increase timeout
While using playwright with proxies sometimes the page is taking more time to load, so how can I increase the load time.
19 Replies
Someone will reply to you shortly. In the meantime, this might help:
@Shine just advanced to level 2! Thanks for your contributions! 🎉
other-emerald•6mo ago
Hi
Did you try to use this code?
try:
await page.goto("https://example.com", timeout=60000) # 60 seconds timeout
except Exception as e:
print(f"Error loading the page: {e}")
rival-black•6mo ago
If you're referring to the PlaywrightCrawler in crawlee
You can increase the default timeout by passing the appropriate parameter to the browser
Update:
Solution - https://discord.com/channels/801163717915574323/1314296091650428948/1314315014118834207
You can pass any parameters that Playwright supports.
https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch
rival-blackOP•6mo ago
I was referring to PlaywrightCrawler
let me try this
I am getting this error
This is the code I am trying
rival-black•6mo ago
The same code without proxy works correctly for me. Even when set to high slow_mo to simulate a slow connection.
Is it possible that the problem is with the proxy?
rival-blackOP•6mo ago
yes proxy is working
checked locally
rival-black•6mo ago
Hmm, I don't have any ideas yet.
The error looks like an attempt to work with a page that no longer exists in the context of browser execution.
I would try to make
request_handler_timeout
higher as its default value is 60 seconds maybe the problem occurs when there is interaction with the element and the handler closes by timeout.rival-blackOP•6mo ago
same error when using apify proxy
I tried in local system with and but still I am getting this error
rival-black•6mo ago
With Apify's auto proxy, it works on my side.
rival-blackOP•6mo ago
the timeout is not changing
rival-black•6mo ago
I apologize, my mistake. That
timeout
only affects the opening of the browser. But not the page open 😢rival-blackOP•6mo ago
yes
I think this should work
rival-black•6mo ago
Yeah, I think that should help, too.
rival-blackOP•6mo ago
now I am not receiving any timeout
rival-blackOP•6mo ago
I need to set the page navigation timeout, is this the only way?
https://playwright.dev/python/docs/api/class-browsercontext#browser-context-set-default-navigation-timeout
BrowserContext | Playwright Python
BrowserContexts provide a way to operate multiple independent browser sessions.
@Shine just advanced to level 3! Thanks for your contributions! 🎉
rival-black•6mo ago
Crawlee doesn't have access to browser context right now,
pre_navigation_hook
is the only way available
So I think that's the best and only way.
https://discord.com/channels/801163717915574323/1314296091650428948/1314315014118834207rival-blackOP•6mo ago
thank you