| || |
Assertions w/ respect to page objects
The page object spec is really cool but also sparse in providing detailed examples. But what it does present is descriptively concise.
Accordingly per the spec, a page object method returns another page object should the action result in navigation to another page. And page objects can return other values like a string, integer, or boolean, to return data to test case where you can then assert against
like the particular example
Inbox inbox = new Inbox(driver);
assertTrue(inbox.isMessageWithSubjectIsUnread("I like cheese"));
But I was wondering, if one has a collective/related set of data to verify against in the page object, what is the generally suggested approach?
* create individual methods that will return the desired data "getDesiredItemName()". Then make assertions in test against the return value for each of these.
* create methods that return a group of data back, stored/represented in some custom defined Java class object, or perhaps a Map/HashMap, or an array? Then selectively or iteratively assert against the values in the returned object.
* or does this indicate your page object is too complex and you need to break it down further? To smaller scope and more page objects?
Asking these questions to see how to make the framework clean and efficient, and yet at the same time minimize bloat (in terms of # of page objects, page object methods, lines of code, etc.). It can get messy for large and complex web applications beyond the simple examples provided in the spec.