[Feature] networkidle for "idle after action"
arjunattam opened this issue · 1 comments
arjunattam commented
Context:
- Playwright Version: 1.0.2
- Operating System: Ubuntu (GitHub Actions)
- Browser: Tried Chromium and WebKit
Code Snippet
await page.goto('https://brewredis-spring-storefront.azuremicroservices.io/');
await page.fill('[placeholder=Search]', 'ipa');
page.on('response', (response) => {console.log('response event', response.url())});
await Promise.all([
page.keyboard.press('Enter'),
page.waitForSelector('mat-card-title')
]);
await page.waitForLoadState('networkidle');
console.log('networkidle');
await page.screenshot({ path: '__tests__/artifacts/search.png' });
On the page,
- I search for a string "ipa"
- Pressing enter loads the search results (shown as result cards on the UI)
- Each result has a corresponding image
I was expecting the page.waitForLoadState
to wait for the network calls that fetch images. But I'm seeing cases (only on CI) where this is not happening.
- GH Actions run for WebKit: https://github.com/arjun27/brewdis/runs/755220115?check_suite_focus=true (see "Run Playwright tests" step, line 34 has "networkidle", and it is in the middle of
- GH Actions run for Chromium: https://github.com/arjun27/brewdis/runs/755197966?check_suite_focus=true
- [Edit] Tried with playwright@next, same result: https://github.com/arjun27/brewdis/runs/755288669?check_suite_focus=true
- Source: https://github.com/arjun27/brewdis/blob/logs/brewdis-ui/__tests__/e2e/index.spec.js
The end screenshot looks like the following, without the images being loaded.
dgozman commented
We do not currently plan to enhance networkidle support, because it's quite flaky - any analytics script can mess it up.
However, here is a gist that does "wait for network settled after action", just in case it is still useful.