Open uchagani opened 2 years ago
We don't support this at the moment. You can defer your network via awaiting time in page.route
as a quick and dirty solution:
await page.route('**/*', async route => {
await new Promise(f => setTimeout(f, 100));
await route.continue();
});
That won't be accurate in terms of latency and throughput, but you can simulate delays in network responses that way.
See here #6038
If you want to enable it on Chromium only, see here: https://github.com/microsoft/playwright/issues/6038#issuecomment-812521882
@uchagani: what is your use case?
a couple use cases but they might be handled by the workaround above:
Since the solution above works for you use case, let's collect more feedback on this.
I think it works for puppeteer :) i used it in codeceptjs wrapper.
public async slowInternet(NETWORK_PRESETS): Promise
If you want to enable it via CDP, see here: https://github.com/microsoft/playwright/issues/6038#issuecomment-812521882
I tried the solution @mxschmitt gave earlier.
I've found that for high values ( >200 ) the Page closes and almost all my tests fail ( it's a bit random which ones fail! ). With a low value ( <100 ) they pass and the delay works ( I have a test where I check a loading element just before the API call resolves ).
Anyone seen something similar? It's a bit strange.
To implement the chrome solution that was posted earlier, I need to access the browser
instance.
I'm a bit confused on how to do this, since I don't have a browser
instance anywhere.
I just run npx playwright test --config=playwright.config.dev.ts
and the tests run.
How do we access the default browser that playwright launches?
If I try to make a new one, all the tests fail.
to answer my question, I realised it's part of the arguments of test()
so
test('My example test', async ({page, browser}) => {
//console.log(browser)
...
})
I cannot get it to work though. I get a
page.goto: Navigation failed because page was closed!
=========================== logs ===========================
navigating to "http://localhost:4001/", waiting until "load"
without the context/cdpSession part, the tests work. :/
edit: seems like with the wifi preset they do, with the 3G one they don't :man_shrugging:
We are prioritizing the features based on the upvotes, recency and activity in the issue thread. It looks like this issue only has a handful of upvotes, has not been touched recently and/or we lack sufficient feedback to act on it. We are closing issues like this one to keep our bug database maintainable. Please feel free to open a new issue and link this one to it if you think this is a mistake.
Added report with articles page testcases
I couldn't find anything regarding this in the documentation but could we get the ability to throttle the network throughput?