how to find all the links present in a web page code example

Example 1: how to find all the links present in a web page

All the link TagName should be "a". 
I locate the webelements starts with tagname "a". 
I also use driver.findElements instead of driver.findElement since the 
list of webelements will return.

List <WebElement>  list = driver.findElements(By.tagName(a))

Example 2: How to find all links in the page

All the link TagName should be "a". 
I locate the webelements starts with tagname "a". 
I also use driver.findElements instead of driver.findElement since the 
list of webelements will return.
List list = driver.findElements(By.tagName(“a”));

Example 3: how to find all link in web pages

All the link TagName should be "a". 
I locate the webelements starts with tagname "a". 
I also use driver.findElements instead of driver.findElement since the 
list of webelements will return.

List <WebElement>  list = driver.findElements(By.tagName(a))

Tags:

Misc Example