想问一下大神们,如何确定图片加载成功呢?是通过帧数还是什么方
selenium吧
全部回复
仅看楼主
level 5
想问一下大神们,如何确定图片加载成功呢?是通过帧数还是什么方法呢?有点无思绪。。。。
2018年08月20日 09点08分 1
level 8
试试这个,这个是我在网上找的
首选获取image标签元素:
WebElement image = driver.findElement(By.cssSelector("div#media_container > img"));
boolean isVisible = this.IsImageVisible(driver, image);
然后判断:
private boolean IsImageVisible(WebDriver driver,WebElement image){
Boolean imageLoaded1 = (Boolean) ((JavascriptExecutor)driver).executeScript("return arguments[0].complete && typeof arguments[0].naturalWidth != \"undefined\" && arguments[0].naturalWidth > 0", image);
if (!imageLoaded1)
{
return false;
}
return true;
}
complete 属性判断有没有加载完成,naturalWidth 判断该图片是否存在
2018年08月31日 09点08分 2
好的,感谢感谢[真棒]。我去试试
2018年09月03日 02点09分
java和python我已经错乱了[心碎]
2018年09月03日 02点09分
1