O'Reilly logo

More Agile Testing: Learning Journeys for the Whole Team by Lisa Crispin, Janet Gregory

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

Appendix A. Page Objects in Practice: Examples

In Chapter 16, “Test Automation Design Patterns and Approaches,” Tony Sweets explained the concepts behind using the Page Object pattern for designing automated tests. Here are code snippets and technical details so that you can try this out yourself.

An Example with Selenium 2—WebDriver

The following piece of code is a Page Object for the Wikipedia home page. It is written in Java using Selenium 2 (WebDriver). This particular Page Object has two public methods (or actions) it can perform. We can either click the privacy link, or we can search Wikipedia using the term “Nissan Motor Company.” These two methods (plus the initializer method, which is known as the constructor) make up this Page Object’s ...

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