首先我上传了一张图片,然后我断言检查我的图片是否在同一个程序中被上传。对于该断言,我定义了以下编码,但它抛出以下错误消息作为失败测试:10 后超时等待元素存在的秒数:By.id:brand.How 我可以动态上传并检查上传的图像是否存在。
WebDriverWait wdw = new WebDriverWait(driver, 40);
ExpectedCondition<Boolean> condition = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
WebElement imageIcon = d.findElement(By.id("brand"));
return "Image".equals(imageIcon.isDisplayed());
}
};
wdw.until(condition);
//Check if Image has been uploaded
WebElement imageIcon = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("brand")));
Assert.assertTrue(imageIcon.isDisplayed());