how to write a code in selenium for 50 links in a webpage 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 broken links in selenium
1-Collect all the links in the web page based on <a> tag.
2-Send HTTP request for the link and read HTTP response code.
3-Find out whether the link is valid
or broken based on HTTP response code.
4-Repeat this for all the links captured.