POM

image

We separate locators, we separate elements, and main code, if change needed we will just change in one place. Makes code clean, better maintenance.

How to write code?

  • What describes one page should be in one class
    • Use class methods to interact with your page
    • This class represents your page in the test code
  • Divide complex pages into smaller components called widgets
    • Create widgets with the same approach as pages
    • Use your pages to initiate and confirm the success of navigation
    • Reuse common widgets in each affected pages (header, footer, sidebar)

Advantages

  • Easy to read test cases
  • Creating reusable code that can share across multiple test cases
  • Reducing the amount of duplicated code - the case of expedia website automation
    • i had the same tests accessing the same elements, if in the future we change we need to change PageClass
  • If the user interface changes, the fix needs changes in only one place

References

https://medium.com/@alipala/4-page-object-model-pattern-6167dc0b5351

SuperMade with Super