It seems to be a best practice to return from one page object the next page object when navigating from one to another
- Martin Fowler: PageObject
"if you navigate to another page, the initial page object should return another page object for the new page" - Getting Started with Page Object Pattern
"When you navigate you should return a page object for the next page"
I have the situation where after the first page object a simple "OK"-dialog informs the user about a status. And after clicking "OK" the next page object comes. Because I have handle such simple "OK" dialog often in the app, I did it till now in a generic way (find inside a "OK"-dialog page object the dialog and press OK). With this approach I cannot return the next page object.
To solve this I see these opportunities where I like to get some feedback on which of them might be the "best" one and what additional ideas you have.
- implement for each of these "OK" dialogs a dedicated one which returns the next specific page object
- create a generic Simple dialog where the type parameter is the next page object and inject the logic to find and return the next page object somehow (possible? how to do?)
- don't follow the best practices and use the current approach where the simple "OK" dialog page object doesn't return the next page object and the "test logic" is resolving and calling the next page object themselves
- let the first page object handle the call of the simple "OK"-dialog page object and then return the next page object from here; this would be fine for a simple "OK"-dialog, but I assume an astonishing coding experience in case it is a more complex "Yes/No"-dialog.
Thanks for your helping thoughts and feedback.
ps: might be important: the programming language is C#