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 – accessing localStorage

Imagine that your application has stored something in the localStorage while the user has been interacting with the application. An example of this might be if you were working in a word processing application and it auto saves what you have typed to the box every so often. If your application were offline, it can still save the information.

Let's see how we would access this.

  1. Create a new test class. You can use the example code at the beginning of the chapter to help you create it quicker.
  2. Accessing the LocalStorage object will require us to case the WebDriver object to it. This is similar to what we saw with BrowserConnection previously.
    LocalStorage storageDriver = (LocalStorage) driver; storageDriver.size(); ...

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