-
Notifications
You must be signed in to change notification settings - Fork 46
Call verifyPage() automatically when a page object is accessed from another page object #39
Description
This is a follow up feature request, I created this issue to avoid polluting Pull Requests (links below).
The idea is: "what if we called verifyPage() automatically when a page object is accessed from another page object (but not if it's created with a factory)?"
from #15 (comment)
I saw this comment in another PR:
"too many things to go wrong. I think it's better to leave it up to the end user. Especially because it also needs to be called from the open() method."
from https://github.com/sensiolabs/BehatPageObjectExtension/pull/30/files#r12889856
But it would be really nice to call all verify() functions automatically when accessing a page object with getPage() from another object.
The way I have it working now is to have all my page object inherit BasePageObject which has
$this->verifyResponse();
$this->verifyPageUrl();
$this->verifyPage();
in its constructor.
However, that means I can't use open() anymore (because when calling open(), the constructor is called first, and the url is not set yet). So I have to create functions in my context file to set the url first.
Maybe changing the getPage() function...?