Working with WebStorage - Selenium

Some of the other technologies that are being developed for HTML5 are related to WebStorage. There are three main WebStorage technologies:

  • Local storage

  • Session storage

  • WebSQL

In this section of the chapter, we will only be working with the first two since WebSQL is not being implemented by all of the browser vendors. These technologies allow us to save to the users' hard disk and then retrieve what we stored.

Let's start using this.

Local storage

In this section, we are going to have a look at working through local storage to make sure that items we expect to be there are there. This is analogous to an integration test that accesses a database to check whether something has been sorted. LocalStorage allows data to be stored and the data is persisted between sessions and the browser being closed and reopened.

The Selenium WebDriver object called LocalStorage is used to access the local storage in the browser.The API is nearly a 1:1 match for the JavaScript API that comes with browsers.

Let's see this in action.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics