I am trying to use the following code from http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_ajax_in_selenium2.html:
String xpathExpr = "//div[@id='contentPane']/div[@class='g-x-Aa ud-Aa']/div[@class='Nj mu']/div[@class='ez vcard']/div[@class='l-Gy Vra']/div[@class='qga']/div[@class='g-Ua-z9']/div[@class='WAa']/div[@class='Yia']/div[@class='twa Vxa']/div[@class='zD us']/div[@class='hx a-f-e']";
//String xpathExpr = "//div[@id='contentPane']/div[@class='g-x-Aa ud-Aa']";
By by = By.xpath(xpathExpr);
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement elem1 = wait.until(visibilityOfElementLocated(by));
System.out.println(Util.getInnerHtml(driver, elem1));
public static String getInnerHtml(WebDriver driver, WebElement element) {
return (String)((JavascriptExecutor)driver).executeScript("return arguments[0].innerHTML;", element);
}
To test some ajax page. The weird thing is that it works the first time but never works after that. Besides the DOM element is loaded in firefox and is clearly visible yet, the program is stuck at the innerhtml part and sometimes wait.until part.
Any idea how to debug and troubleshoot this problem?
Thanks
Ok problem solved. The problem with the CSS class name in xpath I think.