Where does verification belong?

First, let’s take a look at a typical test case:

User do something, then verify expected result,
then user does something else, then verify expected result again
…. and on and on…

See, verification shall belong to where test case logic is defined, and page object class shall not cover test case logic. It shall only define the interaction that user can do with the UI. This way we can keep our page object class clean and uncluttered. and Remember the ‘Single Responsibility’ rule for software development? When a test case is modified, we go modify our test case definition class, and nothing else; And for UI change, we only need to modify our page object class, and not test case class.

To pass information from page object class to test case definition class for verfication, our page object method needs to return a model of the information, and to reduce the duplicate verification code, we can create a verification library.

Of course, if you only need 6 or 7 test cases (Like single digit), you probably will be better off just including assert/verification in page object methods. But if you have a much large set and see test case expansion in the near future, putting verification outside of page object class will pay off.