问题
Using behat/mink, I'm testing the "remember me" functionality. Functionally, when the user visits the main page, javascript/ajax code verifies if the user is "remembered". If yes, then the javascripts redirects to another page. My LoginPage
is defined with $path = '/login.html'
- after the redirect, I will end up on /main.html
.
In my context, I use $loginPage->open()
- however this throws exception Expected to be on "https://example.com/login.html" but found "https://example.com/main.html" instead
. Naturally, this aborts the execution and results in the test failing - yet this is exactly the behaviour I want.
How can I tell behat/mink to not verify URL or ignore URL mismatch?
回答1:
If you check the open() method you will see that the check that fails for you is when is checking the url parameters in verify() method.
If you want to avoid this you can override this method to check only for the response and not the url parameters.
In order to do this you need to extend Page and declare a new method like this:
public function verify(array $urlParameters){
$this->verifyResponse();
}
来源:https://stackoverflow.com/questions/39120549/javascript-redirects-on-page-open