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 ...
Get More Agile Testing: Learning Journeys for the Whole Team now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.