With Selenium
I am not sure Selenium should be used as a link/image checker. In an ideal world you would define which images are on a page, if the images exist you could check their ALT tag. Then your tests verifies those predefined situations are still there.
This blog post shows how you can find images based on their ALT content:
driver.findElement(By.cssSelector("img[alt='Previous']"));
I get the feel you looking for some code that magically detects what images exist on a page and if they are correct. This is what some link checkers do, they check the source of an image or link exists. Then check if they have a ALT text, but do not check the correct value. The tool you linked to is a web-based tool and the magic happens on their back-end. You cannot re-use their work without the back-end code.
This blog post shows how you can loop tru all images on a page with Selenium in Java. If you combine that with the first blog post you can then check the ALT text:
public class findbrokenimages {
static int invalidimg;
static WebDriver driver ;
public static void main(String[] args) {
try {
driver = new FirefoxDriver();
driver.get("http://ruchi-myseleniumblog.blogspot.in");
invalidimg = 0;
List allImages = driver.findElements(By.tagName("img"));
System.out.println("Total images are " + allImages.size());
for (int i = 0; i < allImages.size(); i++) {
WebElement img = (WebElement) allImages.get(i);
if (img != null) {
verifyimgActive(img);
}
}
System.out.println("Total invalid images are " + invalidimg);
driver.quit();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
public static void verifyimgActive(WebElement img) {
try {
HttpResponse response = new DefaultHttpClient().execute(new HttpGet(img.getAttribute("src")));
if (response.getStatusLine().getStatusCode() != 200)
invalidimg++;
} catch (Exception e) {
e.printStackTrace();
}
}
}
Also look into the .getAttribute() function of a WebElement: https://stackoverflow.com/questions/23394828/how-to-get-the-value-of-an-attribute-using-xpath
Open Source LinkCheckers:
I think you are looking for something like this: