Saturday, June 25, 2016

WebDriver - Find All Links

WebDriver - Find All Links

An example of finding all links on a webpage using WebDriver. Suppose we have following ".html" file with 3 links:

Open the file in a browser and it look likes this:

Below is the code which finds all the links on a webpage. We are navigating to a link using Firefox. Next we get all "A" tags using FindElements and iterating through those using ForEach loop.

After the code run, output looks like as shown below: