The term PageObjects has become greatly over-used (including by me).

To reset:

We have element locators.
Sometimes our element locators also have an action (such as click) with them.
Some element locators are at the level but others can be considered to be at fragment, frame, workflow or domain specific grouping levels

These locators are then basically accessed in two ways – directly at the top layer of the test script, e.g. click user_submit_button or by your custom DSL which might be submit_user_form and then the function submit_user_form itself has the line click user_submit_button and user_submit_button is defined at the next lower, page , level.

In either case the 2 key roles that the page object serves are:

  • reduce errors due to duplicate definitions of the same element
  • name the object to make it more readable and easier to maintain

You want the code to read more like

click submit_user_button

and not something like

click(find('div.users span#inputform button'))

Yes we are quite specific and selective and not general functions here but in this case general functions is simply not the only goal in writing this sort of specific test code. We are making code maintainable, that is the goal. I’ve seen code that didn’t use Page Objects and it gets ugly looking fast.

Source link


Please enter your comment!
Please enter your name here