Page Object Model is universally applicable in web test automation
Using Page Object Model wisely to enhance automated test maintenance
--
Last year, I was requested to do a Test Automation POC (proof of concept) in a large financial company. The project manager, under the influence of a principal software engineer, wanted to implement a set of acceptance tests in different frameworks/languages (Java, JavaScript and Ruby). The plan for POC was three months. I accomplished the core tasks within three days.
How? I started with RSpec (Ruby) first, then re-implemented the tests in Java and JavaScript quickly (using a converting script I created). One key practice is that I used the Page Object Model (POM) the same way in all languages (including C# and Python, which were not included in this POC). In the article, I will share my approach.
Table of Contents:· What is Page Object Model?
∘ Demo
· Test Scripts: similar among all versions
· Page Classes: similar too
· How did I create with multiple versions of test scripts quickly?
· If one works well, why bother another language?
· Q & A
What is Page Object Model?
Page Object Model, also known as Page Object Pattern, is a well-known test design pattern in test automation, in fact, it is listed as one of the best practices on the Selenium website. The POM concept existed at least 30 years ago. One test manager (I still remember from Canberra) told me that he was happy to see my tool TestWise with built-in support for POM, which he had used this pattern in the 1980s.
The purpose of POM is “enhancing test maintenance and reducing code duplication” (quoted from the Selenium website). I believe many experienced test automation engineers have heard of it. I covered POM in my book: Practical Web Test Automation, and also in this article: Maintainable Automated Test Design. Read them or other resources on the Internet if you are not clear with POM.
I will continue to show how I used it in that POC.
Demo:
Firstly, I will show executions of a set of Selenium tests, which perform the same testing, but in different languages: Ruby, Python, and JavaScript.