I am testing a Javascript application in Chrome browser. I want to load the page, and once loaded I would like to switch the browser to offline mode.
Note that I DON´T want to start the browser in offline mode as mentioned here: Selenium: How to set browser in offline mode?. Instead I want to start the browser connected and then switch it off and a specific moment.
Note that I don´t want to do it manually with the mouse, because this is for creating an automated test with Selenium. So I need to be able to send the instruction to go offline somehow with a script.
Is there anyway using Chrome to do that? could I modify the browser configuration executing a javascript? (probably not for security reasons but still wondering)
Thanks very much for your help.
As was written in of. release notes:
ChromeDriver v2.26 (2016-12-09)
Resolved issue 984: Extend ChromeDriver capabilities to cover network throttling feature from Chrome DevTools [['OS-All', 'Pri-2']]
Here is full history log about this task. But there is no example, and no answer how it works.
In Python, this can be achieved like this:
driver.set_network_conditions(offline=True, latency=5, throughput=500 * 1024)
PS: I am using ChromeDriver 2.32.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With