Page object model(POM) is one of the most notable design patterns in selenium webdriver. This model is best suited for solving the problem of script maintenance and code duplication issues which occurs while automating multiple pages on websites and eCommerce sites.

Test-automators use POM for automating eCommerce sites because its scripts are reusable. The usage of POM for eCommerce sites is not only restricted to perform functional testing but also to perform acceptance testing when integrated with Cucumber.

Even though POM helps to make the code more readable, more reusable and maintainable there are certain challenges too.

Page Object Model

Page Object Model, a design pattern in selenium, is composed of two classes where web pages and various elements on that page are represented as a single class and functionalities and reusable components of that page are automated in a separate class.

magento 2 QA

Challenges of POM

  • If there is an application with hundreds or thousands of web pages than the time and the effort in the development of automation framework will be high.
  • The cost increases when maintenance overhead increases which are due to the maintenance of large class as they break the OO design principle.
  • The development of POM framework for multiple pages is equal to developers work thus testers should be highly knowledgeable in programming best practices.
  • Page object model is not a generic model and its specific to the applications.

How to overcome the drawbacks of POM?

The best approach to overcome the above challenges is by refactoring the POM concept to Screenplay Pattern. The Screenplay Pattern is an approach to writing high-quality automated acceptance tests based on first two SOLID design principles such as the Single Responsibility Principle and the Open-Closed Principle. Before knowing about the screenplay pattern lets know about the first two principles of “SOLID”.

Single Responsibility Principle: A class should have only one responsibility and it should not be coupled with many responsibilities because a change in one might affect another.

Open Closed Principle: When a new requirement is added or an existing requirement is changed, it should not be updated in an old class instead a new class should be created. This is because a change in one part may result in a cascade of changes.

magento 2 QA

The other principles of “SOLID” are

  • L stands for Liskov Substitution Principle
  • I stands for Interface Segregation Principle
  • D stands for Dependency Inversion Principle

Screenplay Pattern – Highlights

  • Screenplay pattern allows us to write layered tests(layers such as goal, tasks, and actions) which reduce the dependency of one class over another.
  • Screenplay pattern uses actor centric model where several users interact in a scenario.
  • Screenplay pattern supports Serenity BDD.
  • Screenplay pattern favors the concept of inheritance.
  • Screenplay pattern encourages declarative writing style.

All the above are the key features of screenplay pattern which serves as a solution for the drawbacks of Page object model.Thus screenplay pattern serves as the best approach for writing automated acceptance tests which make our script more maintainable and scalable.

We will be writing more about POM in our blogs. Please let us know your thoughts and feedbacks.

References

Be the first to Know

Subscribe to our blog to get the latest articles directly to your inbox.

READY TO DRIVE SALES?

Request a Quote Today

Request a Quote

Leave a Reply

Be the First to Comment!