10

This question asks if the Page Objects pattern for automated GUI testing works for bigger projects. But as the question was focused on a single testing tool/framework I think its a good idea for a bit more general question.

We just started using the Page Objects pattern in a 4Mil LOC product and around 2000 views/pages.

This leads to the following question

  • What are the Pro's and Con's of the Page Objects pattern in large scale projects?
  • Anything you should keep in mind when setting up Page Objects for large scale projects?
6

In my opinion, yes, it does. However there isn't really a single way to implement this model that just works. You have to really think about the structure of your website in terms of it's pages, and figure out how you can represent that structure in your code.

For one company I worked for, I used the page object model against pages that were very simple such that each had a single state. This made it easy for a one class one page approach.

Another company had a website where it's page structure was more app-like that you had a single "super" page with many many states. Using this I created a framework that had a class hierarchy to roughly match the structure of the page states. Rather than a single class single page, I had each "component" that represented a state as it's own class and extended them appropriately. This way each component acted as a container for all it's own inner states, allowing a portion of the page to defined once, then extended wherever necessary.

Hope this helps!

  • 4
    That's the right point. PageObject can model not only whole page but also single components on a page, e.g., table grids. – dzieciou Jun 12 '15 at 9:18
  • I think it's good practice to have page objects be as stateless as possible, and immutable if able. It's makes them much more maintainable long term. If you can clearly define the different states that your page can be in, making a family of page objects that handle a narrower scope of functionality can greatly improve long term maintainability by reducing the scope of error within any single object. But be careful because if poorly planned and executed, it can really clutter your environment and opens a whole new door for maintainability difficulties. – Julian Jun 12 '15 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.