July 2018
Intermediate to advanced
280 pages
7h 27m
English
In the example code, we will filter a list of images that have an empty alt attribute defined. This is useful if you want to check the accessibility of images displayed on the page. As per the accessibility guidelines, all images should have the alt attribute defined. This is done by filtering images, by testing the getAttribute("alt") method; it returns an empty string, as shown in the following code:
@Testpublic void imgAltTest() { List<WebElement> images = driver.findElements(By.tagName("img")); System.out.println("Total Images : " + images.size()); List<WebElement> imagesWithOutAlt = images.stream() .filter(item -> item.getAttribute("alt") == "") .collect(Collectors.toList()); System.out.println("Total images ...
Read now
Unlock full access