How to Train Ajax in Selenium

How to Train Ajax in Selenium
February 21 16:10 2011 Print This Article

AJAX technology is now embedded in almost all web-based application and I was faced with the problem of how to automate the test cases that use AJAX.

AJAX means that the page is reloaded not completely, which speeds up work with the application.

During reload of  the AJAX element Selenium does not see it, and to use just a pause – is incorrect.

I use this trick:

boolean el = false; //logical variable
for (int second = 0; second < 1000; second++) {
try {
if (selenium.isElementPresent(“name”)) {
el = true; // if the item has appeared a logical variable becomes true
break;

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



Related Posts:

  • No Related Posts
  Categories:

About Article Author

view more articles
Nataliia Vasylyna
Nataliia Vasylyna

View More Articles
  • Koen de Roo

    You could also use the command waitForCondition(String javaScript, String timeout)
    It does the same as you are trying to program around. Only setback is that you need javaScript.

    What you could also consider is the more generic command Wait.
    (from the api:)
    new Wait(“Couldn’t find close button!”) {
    boolean until() {
    return selenium.isElementPresent(“button_Close”);
    }
    };