I've faced a problem that in some ui test cases I need to simulate offline internet connection.
I've been using BrowserMobProxy to switch it off with abort()
method but I can not find a way to switch internet on again.
Method start()
does not work as it says that proxy server is already started so I have to create new instance of BrowserMobProxy which can not be done at this stage of test execution.
Is there any other way to switch internet on again?
Here is some code in Java:
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start();
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
DesiredCapabilites capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
WebDriver driver = new ChromeDriver(capabilities);
// some test logic here
proxy.abort();
// some assertions here
proxy.start(); // does not work to switch on internet connection
// some assertion here
Thanks