You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess Puppeteer supports network emulation / throttling. I am looking for something similar using Playwright. I checked the API reference but did not found anything in Network section. Thanks for such a great library.
The text was updated successfully, but these errors were encountered:
@devalevenkatesh Puppeteer's network throttling is done using Chrome DevTool Protocol; you can do the same with chromium in Playwright using context.newCDPSession():
const{chromium}=require('playwright');(async()=>{constbrowser=awaitchromium.launch();constcontext=awaitbrowser.newContext();constpage=awaitcontext.newPage();constcdp=awaitcontext.newCDPSession(page);// Set throttling propertyawaitcdp.send('Network.emulateNetworkConditions',{'offline': false,'downloadThroughput': 200*1024/8,'uploadThroughput': 200*1024/8,'latency': 20});// Go on with the throttled page...awaitpage.goto('https://example.com');})();
This method, however, has a few downsides:
will not work in other browsers in Playwright since there's no CDP
does not work ideally in Chromium either since webrtc and websockets are not throttled
To throttle "for real", we'd recommend user-land solutions:
Charles Proxy is quite popular and works across OS'es.
On Linux, network shaping could be configured per network interface with tools like tc. wondershaper is a convenience wrapper atop of tc and might be a good starting point.
I guess Puppeteer supports network emulation / throttling. I am looking for something similar using Playwright. I checked the API reference but did not found anything in Network section. Thanks for such a great library.
The text was updated successfully, but these errors were encountered: