Thursday, 15 October 2020

Selenium and Service Workers offline mode

I have tests using network throttling on chrome to turn off internet connection. I'm testing SPA. Starting from 85 version of Chrome these tests are failed due to turned on connection. Does anybody know a workaround for this broken function?

Turning off connection using this code:

self.driver.set_network_conditions(
                latency=0,
                offline=True,
                download_throughput=500 * 1024,
                upload_throughput=500 * 1024)

UPD: I have found out when I unregister service workers with chrome dev tools connection loses.

So, my SPA uses service worker as proxy for requests. That's why set_network_conditions() doesn't turn off connection. But, for all other urls there is no connection. I found my issue here.



from Selenium and Service Workers offline mode

No comments:

Post a Comment