First I have uploaded one image and then i made assertion to check my image get uplaoded or not in the same program itself.For that assertion ,I have defined following coding,but it throws the following error message as Failed tests:Timed out after 10 seconds waiting for presence of element located by: By.id: brand.How can i dynamically upload and check that the uploaded image has been present or not.
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());