Chromedriver 91.0.1 setNetworkConditions({offline:true}) with ServiceWorker

93 views
Skip to first unread message

Henry Rose

unread,
Jun 18, 2021, 12:34:35 PM6/18/21
to ChromeDriver Users
I am trying to test out my site's offline behavior using selenium and chromedriver.  I call 
driver.setNetworkConditions({offline:true, latency:0,throughput:0}) returns ok and does not return an error.

However, it appears that this call only sets the network conditions for the main thread not the ServiceWorker too.  I can load pages from my site which not cached by the ServiceWorker when the offline network condition is set.  I would expect to see my ServiceWorker instead display my offline page.  When I try to load google.com, I get an error that the browser is offline like I would expect.  I believe this is showing that the main thread is set offline as expected.

I think this may be related to this chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1068544

Is setNetworkConditions() only being applied to the main thread by Chromedriver?  Is there some way to apply setNetworkConditions to the ServiceWorker as well using chrome driver?

Thanks,
Henry
Reply all
Reply to author
Forward
0 new messages