Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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.

1 Answer

0 votes
by (62.9k points)

A simple approach would be waiting for some "particular" text on that final page, see the "waitForText" command for further info on it. To add more to this approach, you can use the Selenium wait mechanism to check whether the elements on your final page are present or not using the below code:

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. Check the Readme.txt file:https://github.com/prabhpreetk/selenium-google-code-issue-archive

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s automation testing course!

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...