For a (long) while the phrase Page Object has been floating around the periphery of knowledge, but it wasn’t until today that I actually looked it up and actually figured out what it is. And now that I have that knowledge, it seems to me that there are (at least) 3 different patterns for creating a (Selenium) script.
- Feature Flow – These are the classic type of scripts where you automate a flow through an application in a long series of steps.
For additional maintainability and reuse, you will evolve things to include helper methods/fixtures. I would guess that the vast majority of scripts are of this type.
- Page Object – If Feature Flow is ‘functional’ programming, then Page Objects are OO. The webdriver project (which is what is going to power Selenium coming version 2.0) has what appears to be the definitive reference on Page Objects. Essentially, each Page is an Object.
myPage = searchPage()
with all the implementation details are tucked into the search method code.
- DSL – This method is an abstraction layer on top of the implementation details which typically makes the script more consumable by non-technical persons, but also to hide lots of details from technical persons that they don’t want to worry about either.
What I realized is that they are not really exclusive. You can use bot Feature Flows and Page Objects as the underlying logic for a DSL. And in fact, the implementation details that are encapsulated in the Page Object methods will look like Feature Flow code.
There has got to be other patterns also out there that I haven’t heard of. But what are they?