Let's start with a simple test to determine the links displayed on the home page of the sample application. We get all the links from the home page and print their count, followed by the count of links that are visible on the page, as shown in the following code:
@Testpublic void linksTest() { List<WebElement> links = driver.findElements(By.tagName("a")); System.out.println("Total Links : " + links.size()); long count = links.stream().filter(item -> item.isDisplayed()).count(); System.out.println("Total Link visible " + count);}
In the preceding code, we used the findElements() method along with By.tagName to get all the links from the home page. However, for finding out the visible links out of them, ...