4

I need to disable internet during web automation test using selenium webDriver, then test UI and enable connection.

I'm using selenium (PageFactory) to create scripts, maven to build project... My test case is - I need to start selenium script (open browser - login) then disconnect internet then test that error appear on web site and then connect again. I need to do it on different OS (Windows/Mac) and browsers Thank you for any help.

Ihor Bovkit
  • 120
  • 3
  • 9
  • 1
    Please explain in more detail what you are doing. Your setup etc etc. Everything that would be needed for someone to duplicate your problem. – gfelisberto May 11 '16 at 16:27
  • Hi, I'm using selenium (PageFactory) to create scripts, maven to build project... My test case is - I need to start selenium script (open browser - login) then disconnect internet then test that error appear on web site and then connect again. I need to do it on different OS (Windows/Mac) and browsers – Ihor Bovkit May 12 '16 at 21:25
  • How is it related to the question marked as a duplicate? Aren't they totally different things? And why is the older question closed in favor of the newer one? – S.Khajeh May 23 '22 at 13:53

1 Answers1

0


Selenium can only be used to drive browsers and not any Desktop/Windows application.
Since its a simple network disable, you can run commands through Java language as below
1. To disable network in Java on Windows
    Runtime.getRuntime().exec("netsh wlan disconnect");
2. Run your selenium script.
3. Now enable using the code:
    Runtime.getRuntime().exec("netsh wlan connect name="network_name" ");

Shamanth
  • 19
  • 3
  • hi, what if I need to start selenium script (open browser - login) then disconnect internet then test that error appear on web site and then connect again Do you think your suggestion will work? – Ihor Bovkit May 12 '16 at 21:23