public class PrintAllLinks
{public WebDriver driver;
private static String[] links = null;
private static int linksCount = 0;
@Test
public void DisplayAllLinksNames() throws Exception{
driver.manage().timeouts().implicitlyWait(9,TimeUnit.SECONDS);
driver.get("http://seleniumsubbu.blogspot.in//");
List<WebElement> alllinks = driver.findElements(By.tagName("a"));
linksCount = alllinks.size();
links= new String[linksCount];
System.out.println("Print All links on a web page :");
for(int i=0;i<linksCount;i++)
{
links[i] = alllinks.get(i).getAttribute("href");
System.out.println(alllinks.get(i).getAttribute("href"));
}