Creating a Page Objects framework

Now that we have a theoretical knowledge of Page Objects, let's put it to use. When building a new Page class, we can take multiple approaches to implement. We can use any tool that our OOP language provides for us. For this example, we will be using the inheritance as a way to quickly create new Page classes.

Note

Inheritance is a feature of OOP languages, which allows new classes to be based on another class, creating a subclass. The newly created subclass inherits all of the functionality of the parent class.

The majority of the web pages on our site follow a similar pattern of display: header, body, sidebar, and footer. This means we can create a generic Page class that will provide us with access to different ...

Get Selenium Design Patterns and Best Practices 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.