Pages

Search This Blog

Thursday, May 20, 2010

How to make selenium to wait for an element every second

Sometimes waitForPageToLoad() and pause fails then to handle this condition we just need to wait for an element we are waiting to load on the page. Once its loaded our execution should proceed.


boolean Condition = false;
for (int second = 0; second < 60; second++) {
try {

if ((selenium.isElementPresent("//a[@id='overridelink']"))) {
selenium.click("//a[@id='overridelink']");
Condition = true;
break;
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);

}

}
catch (Exception ignore) {
}
pause(1000);
}
assertTrue(Condition);

6 comments:

  1. are bhai
    Thread.Sleep(2000);
    use kar lo

    from: anilit@in.com

    ReplyDelete
  2. I like what you guys tend to be up too. This kind of clever work and reporting!
    Keep up the very good works guys I've included you guys to our blogroll.

    Feel free to visit my blog; http://peskarmanak.blogspot.com

    ReplyDelete
  3. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium

    ReplyDelete
  4. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  5. Well explained. Got to learn new things from your Blog on Appium.
    Appium training in chennai

    ReplyDelete
  6. It was very nice blog to learn about Selenium.Thanks for sharing new things.selenium training in chennai

    ReplyDelete