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

LoadableComponent

LoadableComponent is another way to approach PageObjects. LoadableComponent is a base class that all of the pages need to extend. The base class has the following methods on the interface:

  • get()
  • isLoaded()
  • load()

Instead of the usual public class PageObject, we change it:

public class PageObject extends LoadableComponent<PageObject>

We will have to add overrides for the load() and isLoaded() method . The load method will load the page for us and the isLoaded() method can allow us to check if the page has been loaded correctly.

For example:

@override Protected void load() { selenium.get("http://book.theautomatedtester.co.uk"); } @protected void isLoaded() { String url = selenium.getCurrentUrl(); If (url != "http://book.theautomatedtester.co.uk"){ ...

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