0
我試圖從http://www.thoughtworks-studios.com/twist/2.3/help/how_do_i_handle_ajax_in_selenium2.html使用下面的代碼:Ajax和硒工作間歇
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);
}
爲了測試一些Ajax網頁。奇怪的是,它第一次工作,但從來沒有工作。除了DOM元素在firefox中加載並且清晰可見之外,該程序還停留在innerhtml部分,有時候會等待。部分。
任何想法如何調試和解決這個問題?
感謝