Click on a link triggers an operation that creates new element. However, calling driver.findElement(By.id(""))
after click returns does not find it.
I have tried the following code to wait for the element to appear.
wait.until(new ExpectedCondition()
{
public Boolean apply(WebDriver webDriver) {
System.out.println("Searching ...");
return webDriver.findElement(By.id("itemType1")) != null;
}
});
But I still can't find it until timeout.
You can maybe use the element.isDisplayed()
Så do it like this:
WebElement jrnrText = driver.findElement(By.id("id"))
if(jrnrText.isDisplayed()){
wait.until(presenceOfElementLocated(BY.id]("id")))
}
Function<WebDriver, WebElement> presenceOfElementLocated(final By locator) {
return new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator)
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.