Automated Testing Tech Object Pattern

we createPage Object Pattern in Automated Testing

Innovation|Personal Development|Benefits

Page Object Pattern in Automated Testing

Automated tests are valuable objects for any agile software development team. These are the tools that find bugs quickly during early phases of software development cycles. This article explains how the usage of Page Object helps in automated testing.

Ted Talk oleg SE

Automated Testing by Itself

Writing automated tests is a need. When there are new features that are still in development stage, such tests can be run. And, it will show how other parts of the system are affected by those changes. Although it might seem like a piece of cake, we can end up with poorly implemented tests, and high cost of code maintenance in any agile process. The change of one element on a web page that another tests rely on needs one to go through these piles of test routines. It’s not only a big time-consumer, but a serious demotivator as well. What if it’s possible to make a change in one place only? And have each relevant test routine use it? Fortunately, we’re lucky to have Page Object models which write readable, maintainable and reusable tests.

What is Page Object Model

Page Object Model is a design pattern that enhances test maintenance and reduces code duplication. It serves as an interface to a page of your  AUT (Application Under Test). With the help of this approach, it’s possible to depict the screens of your web app as a series of objects and enclose the features represented by a page. POM can be used in any kind of framework such as date-driven, keyword driven, modular, hybrid framework etc.

Pros of POM

There are lots of advantages that we can speak about, but let’s focus on the most essential of them.

Code reusability – we can achieve it by writing a code once and using it in different tests. As a result, test cases become short and optimized.

Object Repository – Keeping separate repository for page objects helps us to use this repository for different purposes with different frameworks.

Code maintainability – due to a clean separation between test code and page specific code such as locators and layout, it becomes very easy to maintain code. Code changes only on Page Object Classes when a UI change occurs. It results in enhancing test maintenance and reducing code duplication.

What does POM mean to a “lazy QA”

  • No coding for each page. Just the usage of existing model.
  • An element from group of elements is accessible by index: page.checkboxes.click(element_index)
  • A compound part of page with different elements…: page.table.extracted_line.button.click()
  • You don’t think of the way how to get and set values, just use element.value = “TEXT” or print(elem.value)
  • You can get access to all attributes of the element: element.attributes
  • If the page address depends on session, it’s good to create a chain of actions that leads to a specific page.
  • The page can be created, saved in a file, downloaded and modified. Moreover, you can share a page with a friend.
  • Compound parts of pages are shared independently.

Share this event