I'm looking for canonical answers explaining the importance and advantages of the Page Object Model design pattern, specifically answers that I could point to for people who claim the pattern is unnecessary or outdated, or who claim to offer a "better" alternative. We have a lot of answers scattered around the site but nothing that could be considered canonical. Here are examples of the better ones I've found, but they are either quite old or only address one aspect of the question:
- What is page object modelling? and Why is it so important?
- In Page Object pattern, aren't we creating over-specialized methods than generalized re-usable functions?
- What are the trade-offs of using page objects instead of a collection of functions in UI automation?
- How you decide the right level of function abstraction in Page object model?
- How do I convince someone who's bought the Record-Playback line that object oriented framework is essential?
Some common counterarguments that the answers should address:
- The Page Object Model involves too much "ceremony"/YAGNI.
- You shouldn't be using your UI to set up state--just use the back end to do that and then test your UI from there (example: https://stackoverflow.com/questions/50685302/page-object-pattern-in-cypress - I believe this has some merit but I don't believe it completely eliminates the advantages of having Page Objects).
- I'd list the record-and-playback pitch but I think the last question in my list above covers it pretty well. I'm sure others with more experience have heard other arguments as well, which I'd appreciate their responses to.
- POM leads to excess code and maintainability issues
Answers should also provide some guidance on how to implement the POM pattern to avoid common pitfalls.