Reputation: 991
The default wait time for networkidle to fire in PlayWright is 500 milliseconds - is it possible to increase that? I've looked everywhere and can't seem to find a way to do that.
Upvotes: 4
Views: 4184
Reputation: 4207
Playwright performs a range of actionability checks on the elements before making actions to ensure these actions behave as expected. It auto-waits for all the relevant checks to pass and only then performs the requested action. If the required checks do not pass within the given timeout, action fails with the TimeoutError.
Note: Networkidle is quite flaky - any analytics script can mess it up. Please don't rely on it in your tests.
Navigating to a URL auto-waits for the page to fire the load event. If the page does a client-side redirect before load, page.goto() will auto-wait for the redirected page to fire the load event.
// Navigate the page
await page.goto('https://example.com');
In lazy-loaded pages, it can be useful to wait until an element is visible with locator.waitFor(). Alternatively, page interactions like page.click() auto-wait for elements.
// Navigate and wait for element
await page.goto('https://example.com');
await page.getByText('Example Domain').waitFor();
// Navigate and click element
// Click will auto-wait for the element
await page.goto('https://example.com');
await page.getByText('Example Domain').click();
Source: https://playwright.dev/docs/navigations#:~:text=Auto%2Dwait%E2%80%8B,to%20fire%20the%20load%20event.
Upvotes: 3