From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

What is page object model?

What is page object model?

Page object model is a design pattern where you create object models for your pages that is simple classes for your website pages and the related actions. To understand the same we'll go ahead and use the sample app from the UI testing playground where we created test cases for the login form. First of all, we started by navigating to the sample app page. Then we created two test cases, one for successful login, the other for failed login. In the functions, we go ahead and locate the input fields, the login button. Then we go ahead and fill in our username and password. Then we go ahead and click in the login button to actually log in. Then we go ahead and check the label which is our login status for the welcome message and the successful login and the error message in the field login. Now what we did here is repeated this bit of code in both of the test cases. So what we can do is create a page object model that is a login page class which goes ahead and takes care of the…

Contents