WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
try{
WebElement myDiv = wait.until(ExpectedConditions.visibilityOfElementLocatedBy(By.xpath("//div[@id='mydiv']"));
}
catch (Exception ex) {
// deal with timeout...
}
try{
wait.until(ExpectedConditions.stalenessOf(myDiv);
}
catch(Exception ex) {
// deal with timeout...might want to check for null before try here
}
//now do whatever it is you want to do...
//if you need to work with this element, you'll want to grab the reference again
1条答案
按热度按时间oewdyzsn1#
这里有一个简单的例子...(未经测试):