I using Selenium 2 and Java 1.7. I want to wait my HtmlUnitDriver until ajax done when i clicked filter button.
My driver:
Webdriver driver = new HtmlUnitDriver(true);
Filter button and click action:
WebElement weFilterButton = driver.findElement(By.name("filterButton"));
weFilterButton.click();
I tried three ways for wait AJAX done.
first:
WebElement el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ctl00_ContentPlaceHolder1_Reports1_ajaxloadingImage")));
second:
Boolean el = wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
JavascriptExecutor js = (JavascriptExecutor) driver;
return (Boolean) js.executeScript("return document.readyState").toString().equals("complete");
}
});
and although it is not a good solution
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
but is not work.
EDIT
Selenium dependency is :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
Aucun commentaire:
Enregistrer un commentaire