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:
Create a new test class using the example code at the beginning of the chapter.
We can call the class TestBrowserConnection.
Create a test method and add the following to it:assertTrue(((BrowserConnection) driver).isOnline());
Your class should look like the following and when you run the test method it will pass:
What just happened?
We have seen that by casting the webdriver object to BrowserConnection, we have access to a number of new methods. These methods allow us to see if the browser is currently online or offline. They also allow us to set the browser to online or offline, which will be the next section of this book.
Setting the browser offline or online
Now that we know how to see if the browser is online or offline, let us have a look at setting the browser connection to online or offline. This is not part of HTML5 technologies, but will allow us to use the previous online call, which is part of HTML 5, and to check if our application cache has downloaded the relevant files.
Let's see this in action.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.