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 sessionStorage

Imagine again that you are working against a word processing application but instead of it auto saving the text that you type to somewhere that is persisted, you only save it briefly waiting for the user to click save.

Let us see how we can use it.

  1. Let's just add a new testMethod to the class we created in the previous section. We can call it testShouldAccessSessionStorage().
  2. We will need to cast the WebDriver object to a SessionStorage object, so we can start accessing the methods it has available like the following:
    SessionStorage storage = (SessionStorage) driver;
    assertEquals(0, storage.size());
  3. Let's create our test and run it. It should look like the following:
    import org.junit.*; import org.openqa.selenium.*; ...

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