-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Some requests not intercepted without waitFor(2000)
#996
Comments
I'm using 0.11, so I've rewritten your script using const { chromium, webkit, firefox } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.route(/^https:\/\/www\.behance\.net/, request => {
console.log('request', request.url());
request.continue();
});
await page.goto('https://www.behance.net/search');
// If looks like page-side router is installed in JavaScript lazily.
// - If you don't wait, click produces the navigation to `/search/moodboard` that
// contains all the data required to render the page.
// - if you do wait, `history.pushState` is used to navigate and `XHR` is issued
// to fetch the data.
// You either need to wait for the router to be installed or to intercept both XHR
// and `/search/moodboard`.
//
// Btw, it does XHR for me on Chromium, bug WebKit and Firefox do the
// navigation if I don't wait here. I believe that is a timing issue.
await Promise.all([
page.waitForRequest(/search\?content\=moodboards/),
page.click('[data-ut="moodboards-tab"]'),
]);
await browser.close();
})(); |
Thanks very much @pavelfeldman. This explanation is super helpful. In my case I was able to make it work simply by doing this: await Promise.all([
page.click('[data-ut="moodboards-tab"]'),
page.waitForNavigation({ waitUntil: 'networkidle0' }),
]); I'm not sure this is the very best way, since JS bindings may be ready well before all network requests are complete, but this does the job. |
waitFor(2000)
waitFor(2000)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context:
Code Snippet
Here's a minimal repro of the behavior I'm seeing.
Describe the bug
Hey there. Thanks for building this great tool!
I'm having an issue with request interception not working all the time. If I don't wait for 2s or more after loading my first page, I can't see any XHRs that that page makes. However, if I do wait for 2s or more, I can see the XHR.
Here's the output the script generates:
# Without 2s wait request https://www.behance.net/search requestfinished https://www.behance.net/search request https://www.behance.net/search requestfinished https://www.behance.net/search request https://www.behance.net/assets/img/footer/icon-ad-choices.png requestfinished https://www.behance.net/assets/img/footer/icon-ad-choices.png request https://www.behance.net/v2/an/pv request https://www.behance.net/search/moodboards requestfinished https://www.behance.net/v2/an/pv request https://www.behance.net/assets/img/footer/icon-ad-choices.png requestfinished https://www.behance.net/search/moodboards requestfinished https://www.behance.net/assets/img/footer/icon-ad-choices.png request https://www.behance.net/v2/an/pv requestfinished https://www.behance.net/v2/an/pv
The text was updated successfully, but these errors were encountered: