Page Object Model (POM)

Page Object Model (POM) image
Page object model is a design pattern used in test automation where test script and locators are defined in separate classes. In this design pattern each web page( screen in case of mobile application) is represented as a class and each element on the page is represented as an object. All the locators of the web page and actions on those locators are defined on the corresponding page created in the test automation.

Advantages of POM:
  1. Maintainability: Modification in the UI pages often happens and so there are chances that test cases may fail due to locator change. So it’s easy to update the locator at one place and thus fixing the test cases failing due to locator change
  2. Reusability : Having locators at one place, It becomes easy to reuse throughout the test framework wherever it’s required. We need not define it in each test class.
  3. Readability: With the locator defined in other class using POM, it gives clear and readable code at the test layer making it more clean
The Page Object Model is a design pattern used by frameworks such as Selenium and Playwright when testing user interfaces (UI).

The “page object” only models the areas of the UI that tests will interact with. These page models are files made up of locators and functions relating to a single UI-view, meaning any changes to the UI impacting an automated test needs to be maintained in a single location and code is less likely to be duplicated across the test automation framework. The tests then use the locators and functions of the page object whenever they need to interact with the UI of that page. The same principles used for page objects can be used to create “Page Component Objects”, that represent discrete chunks of the page that can be included in page objects.
Explore MoT
Don’t Be Left Behind: Close the Gap Between Test and Delivery image
Wed, 12 Nov
Align testing and delivery to reduce lead time and improve deployment frequency.
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
This Week in Quality image
Debrief the week in Quality via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.