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);

2 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