I have a web application which has around 500 pages. Can we use POM framework and if so, is it a good practice? if not, please suggest some ideas.
- THINK BIG; We are going to automate everything! I am so excited!
- act small; Automate a single user flow. (Not login, but a real end-to-end behaviour, login might be part of this.)
- Fail fast; Struggle...
- Learn rapidly; Retrospect, inspect and adapt, decide on the next experiment and goto act small.
I love simple PageObjects as pattern. Not as a "framework". Page Object Models and Factories are probably over-engineering. During your struggles and learning decide if you want to go bigger with more complexity in your framework.
It won't be perfect from the start. Every domain, industry and team has different needs, so there is not standard or silver bullet. Iterate, while improving continuously and rigorously.
Test-code is code. Use practises/patterns like PageObjects, DRY, CleanCode, Solid, etc...
A few years ago I asked a similar question: Does the Page Objects pattern scale? I think it does. Once you have enough pageObjects, writing new test-cases for existing views becomes so easy.
Well, first I would ask these questions:
- Do you really need to write Selenium test for all of these 500 pages?
- Do your developers write enough and good Unit tests?
I assume it is a Single Page Application and for sure there are so many common components between these 500 pages i.e they are not 500 unique pages with completely different behaviours and functionality.
I recommend to follow the Test Pyramid and make a list of test cases which are not covered by low level tests. Then go with any solution/design which are scalable, fast and not flaky and easy to configure & maintain (for example puppeteer).
As a simple answer to your question: Page Objects scale well.
And more on the guidance side of things...
Should you be testing 500 variations on the same pages using 500 unique page objects? No, probably not.
A set of pages that allow tests to check what features are enabled on the page at a given time would be a more sensible way to handle this. E.g.
Small text differences are also easily checked in this manner