Page Object Model Basics

Page Object Model Basics

One the more popular design patterns for Selenium is the Page Object Model. The general idea of page object model is to programmatically model each page for the tested website in classes separate to your test cases. Each class will implement logic specific to that page. In your test cases you will mainly be entering commands written in these Page classes.

To provide an example: a Login page might have a method which enters the username and a separate method for the password, it might even have a process which enters the username, password and clicks the login button. In a test case testing this Login page, the test will create the Login Page Object which will allow you to programmatically interact with this page as if it were any other Object in your programming language.

As roughly shown above, this design pattern strongly favours those who are familiar with Object Oriented Programming as it literally models pages as Objects typically used in those languages. Not only does it make it easier to read and understand test cases, but it also drastically speeds up the process of writing tests as you are able to reuse Page Objects in any other test case. This model also significantly decreases the maintenance burden for testing as you only need to make changes in one class to fix every instance of that broken method in each test case which uses it.

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.