1.

My Application Uses Ajax Heavily How Do I Use Selenium Rc To Work With Ajax Operations?

Answer»

Ajax operations don’t RELOAD a page like normal form submission but they MAKE http requests behind the scene. You cannot use waitForPageToLoad for such operations and instead should use conditional wait for change in state of application. This could as well mean waiting for presence of an element before continuing with test operations. Consider FOLLOWING example in which type operation triggers Ajax operation which is followed by conditional wait for presence of a text box

// type operation BRINGS element “q” on screen without loading the page

selenium.type("elementLocator","testData"); // conditional wait for element “q” for(intsecond = 0;; second++) { if(second >= 60) FAIL("timeout"); try {if(selenium.isElementPresent("q"))break;}catch(Exception e){} Thread.sleep(1000); }

Ajax operations don’t reload a page like normal form submission but they make http requests behind the scene. You cannot use waitForPageToLoad for such operations and instead should use conditional wait for change in state of application. This could as well mean waiting for presence of an element before continuing with test operations. Consider following example in which type operation triggers Ajax operation which is followed by conditional wait for presence of a text box

// type operation brings element “q” on screen without loading the page



Discussion

No Comment Found