I\'m using Selenium (within PHPUnit) to test my web application. I would like to test whether a certain image which is present on the page really exists. More precisely, whe
Well, in chrome one can write code in java to get the list of image src
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class imageUrl {
public static void main(String[] args) {
//Create Driver-object for chrome browser
System.setProperty("webdriver.chrome.driver","//Users//admin//Desktop//chromedriver");
WebDriver driver = new ChromeDriver();
//get the page
driver.get("https://jet.com/");
// this will find the elements by tag name. Don't forget to write "WebElement" after List.
//or else it will give an error on the for loop
Listlinks=driver.findElements(By.tagName("img"));
// this will display list of all images exist on page
for(WebElement ele:links){
System.out.println(ele.getAttribute("src"));
}
}
}