Javascript redirects on page->open

谁说我不能喝 提交于 2019-12-11 04:14:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!