At times, we may come across elements of same type like multiple hyperlinks, images, etc. arranged in an ordered or unordered list. Thus, it makes absolute sense to deal with such elements by a single piece of code and this can be done using WebElement List.
Below is sample code written for the same:[java]
// Storing the list
List elementList = driver.findElements(By.xpath(“//myxpath”));
// Fetching the size of the list
int listSize = elementList.size();
for (int i=0; i<listSize; i++)
// Clicking on each service provider link
// Navigating back to the previous page that stores link to service providers
The above written code is the basic code . You can enhance it as per your requirement.