O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – setting the browser connection to offline or online

In this section, we are going to turn the device's browser connectivity off. This means that we can check how the application works if it were offline. This is going to be a really useful feature as more and more applications try to take advantage of the move to mobile.

Let's see this in action.

  1. We are going to create a new test method in the class that we created in the previous section.
  2. In the test we are going to need to set the browser offline. We do this by casting to BrowserConnection and then using the method setOnline(). If we pass in true, it will set it online and if we set it to false, it will set the browser offline. Following is an example:
    ((BrowserConnection) driver).setOnline(false); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required