Here is how you can find all the Links on a Webpage with Selenium WebDriver in Java.

All you need to do is to create a list of all WebElements, and then iterate thorough the list of links to print the link and the text of the link:

List allLinks = driver.findElements(By.tagName("a"));

System.out.println("All links found on web page are: " + allLinks.size() + " links");

for (WebElement link : allLinks) {

//print the links i.e. or

//print the links text

To get the link you can call the “getAttribute” method on the link WebElement passing “href” as its argument which will print the links as i.e. or is a cloud testing platform: