How to get Selenium to wait for a transition page to redirect before running an assertion How to get Selenium to wait for a transition page to redirect before running an assertion selenium selenium

How to get Selenium to wait for a transition page to redirect before running an assertion


A simple approach would be wait for some "particular" text on that final page, see "waitForText" command for further info on it


To add to John's approach, you can use the Selenium wait mechanism to verify that elements on your final page are present like so:

Java:

WebDriverWait wait = new WebDriverWait(webDriver, 10); // secondswait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foo")));

Ruby:

wait = Selenium::WebDriver::Wait.new(timeout: 10) # secondswait.until { driver.find_element(id: "foo") }

This will properly follow any redirects involved.

Example from https://code.google.com/p/selenium/wiki/RubyBindings


You could call wait_for_page twice in a row. The first waits for the redirect, the second for the final page.