29

I have a fairly standard situation: Click a button, it loads a transition page with a progress bar or something, and then that page redirects to the next page, which takes a while to load.

I want to run assertions on the final page, not the transition page. How do I tell Selenium IDE to wait till the final page loads before performing the assertions?

Thank you.

marc esher
  • 4,871
  • 3
  • 36
  • 51

4 Answers4

17

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

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
John
  • 1,681
  • 3
  • 20
  • 28
11

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); // seconds
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foo")));

Ruby:

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

This will properly follow any redirects involved.

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

Robin
  • 1,438
  • 2
  • 19
  • 29
josh-cain
  • 4,997
  • 7
  • 35
  • 55
3

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

Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
0

You can also wait until the page title is an expected value:

$driver->wait()->until(WebDriverExpectedCondition::titleIs('New page title from redirect'));
Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
CIRCLE
  • 4,501
  • 5
  • 37
  • 56