Skip to content
Advertisement

Kill network connection in the middle of the test using Selenium Java

I’m trying to kill my network in the middle of a test. and when I kill the network, the system should prompt a dialog saying network is gone. When I do this manually, I get the dialog. And I used the following code,

JavaScript

When I run this code, it won’t give me that dialog. but, when I refresh the page, it tells me that there’s no network.

What did I do wrong?

Manual Steps –

  1. Go to the url
  2. Successful login
  3. Network drop
  4. Dialog appears

Advertisement

Answer

I could turn of internet using the bash command,

JavaScript

and turn it back on using,

JavaScript

This will automatically turn off your wifi and turn it on again.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement