RE: How to verify the Changing Images in a Website using Selenium Webdriver

Answered

Hi All,
In our application there is a scenario like ,there are some images which changes continuously from time to time.. How should we verify those images whether they are present on website or not?
Please help me.

RavinderReddy Train Asked on September 26, 2014 in Selenium WebDriver.

Nice question (Up vote for this) and have you tried this? or directly you need code?.

on September 27, 2014.

Since this question is very old, Is this still open for discussion, I found near by one working answer to this problem.  ???

on April 22, 2015.
Add Comment
8 Answers

Hi Ravinder Reddy,

To verify whether image is present or displayed or not, please use below code sample. May this will help for you.

Absolute xpath is not good when you have dynamic identifiers (As I know).

driver.get(“https://www.vodafone.in/pages/home_kar.aspx?cid=kar”);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(“//img[contains(@src,’../_layouts/images/vf/banners/herospace/923201430138PM_HB(1).jpg’)]”)));
if(driver.findElement(By.xpath(“//img[contains(@src,’../_layouts/images/vf/banners/herospace/923201430138PM_HB(1).jpg’)]”)).isDisplayed()){
System.out.println(“923201430138PM_HB(1).jpg Displayed”);
}else{
System.err.println(“Not displayed”);
}
driver.quit();

Doctor Answered on September 27, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.