mercredi 27 mars 2019

Multiple ways of performing an action with the page object pattern

When implementing the page object pattern, the recommendation that I've seen is that actions should be high-level, instead of individual UI actions:

For example:

page.search(query)

Rather than:

page.enterSearchBarText(query)
page.clickSearchButton()

However, the search should also execute when the user hits Enter instead of clicking the search button.

So search could also be:

page.enterSearchBarText(query)
page.pressEnter()

If I want to cover both in my tests, what is a conventional way of implementing this? I thought perhaps

search(query, method)

where method could be one of enum { SearchButton, Enter }

Aucun commentaire:

Enregistrer un commentaire