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 – seeing if the browser is online

In this section, we will have a look at seeing if the browser is online or offline. Currently, this only works on mobile drivers from Selenium WebDriver. In this section, we will need to cast the Selenium WebDriver object to BrowserConnection and then access the methods that are found on that object.

Let's get into action:

  1. Create a new test class using the example code at the beginning of the chapter. We can call the class TestBrowserConnection.
  2. Create a test method and add the following to it:
    assertTrue(((BrowserConnection) driver).isOnline());
  3. Your class should look like the following and when you run the test method it will pass:
    import org.junit.*; import org.openqa.selenium.*; public class TestChapter10 ...

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