8

I am writing a selenium test and I need to assert that the page is redirected. How should I verify this? What would be the best way?

I am using PHPUnit and the PHPUnit_Extensions_SeleniumTestCase.

Andrew
  • 227,796
  • 193
  • 515
  • 708

2 Answers2

8

assertLocationEquals - Reports an error if the current location is not equal to the given $location.

$this->assertLocationEquals($someNewUrl);
s_hewitt
  • 4,252
  • 24
  • 24
0

I might also add a

$this->selenium->waitForPageToLoad("30000");

or if you're really paranoid, a

sleep(1);

In between the page's call to redirect and the check to see that the new URL loaded. That should help serve as a buffer in the event of a slightly slower web server response.

Alex C
  • 16,624
  • 18
  • 66
  • 98