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

No comments:

Post a Comment