更新时间:2023-11-10 12:22:10
您可以执行一些JavaScript来查询DOM.具体来说,是 HTMLImageElement 的complete
属性.. >
You could execute some javascript to interrogate the DOM. Specifically, the complete
property of an HTMLImageElement.
public static void waitUntilVisible(WebDriver webDriver, By locator) {
WebDriverWait driverWait = new WebDriverWait(webDriver, TIMEOUT);
WebElement el = webDriver.findElement(locator);
driverWait.until(
new Predicate<WebDriver>() {
public boolean apply(WebDriver driver) {
return ((JavascriptExecutor)driver).executeScript("return arguments[0].complete", el);
}
}
);
}
但是请注意,complete
:
如果浏览器已完成获取操作,则返回一个布尔值,该布尔值为true 图像,无论是否成功.如果图像还显示为真 没有src值.
Returns a Boolean that is true if the browser has finished fetching the image, whether successful or not. It also shows true, if the image has no src value.