You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.
I encountered an issue with testing the current URL followed by clicking an element. I have no problem testing any internal path (e.g I should be on "/" or I am on "/"). However, the test with the line:
Then I should be on "https://www.example.ca"
it gives me an error that says
Current page is "/", but "" expected. (Behat\Mink\Exception\ExpectationException)
I created AfterStep method that prints out the current URL, and I could see that the link is not broken and is redirecting the page to the right URL as it is printing out the address I am expecting to see.
Edit: cleanUrl method is being called in addressEquals, and the method returns / when https://www.example.ca is passed as a parameter which makes sense why the test is failing. Is there a way to get away from this issue other than implementing a custom method?
Edit: Here is my work around this issue:
/**
* @Then current url is :page
*/
public function currentUrlIs($page)
{
$this->addressEquals($this->locatePath($page));
}
/**
* @return true if the given address matches with the current url
* false, otherwise
*/
private function addressEquals($page)
{
$expected = $page;
$actual = $this->getSession()->getCurrentUrl();
$this
->assert(strpos($actual,$expected) !== false, sprintf('Current page is "%s", but "%s" expected.', $actual, $expected));
}
/**
* @throw Exception when the condition is not met
*/
private function assert($condition, $message) {
if ($condition) {
return;
}
throw new \Exception($message);
}
Any help would be appreciated. Thank you :)
The text was updated successfully, but these errors were encountered:
Hi,
I encountered an issue with testing the current URL followed by clicking an element. I have no problem testing any internal path (e.g
I should be on "/"
orI am on "/"
). However, the test with the line:it gives me an error that says
I created AfterStep method that prints out the current URL, and I could see that the link is not broken and is redirecting the page to the right URL as it is printing out the address I am expecting to see.
Edit:
cleanUrl
method is being called inaddressEquals
, and the method returns/
whenhttps://www.example.ca
is passed as a parameter which makes sense why the test is failing. Is there a way to get away from this issue other than implementing a custom method?Edit: Here is my work around this issue:
Any help would be appreciated. Thank you :)
The text was updated successfully, but these errors were encountered: