RE: am new to selenium webdriver how to run the multiple sites and check all the sublinks are working or not from excel sheet using data driven method


hi am new to automation
am getting problem to check all the websites and their sublinks from excel sheet using webdriver and how can implement the reports to a specified mail id

Add Comment
2 Answers
Best answer

Hi balajinatarajan,

I will give a small example.  Lets get all the links for site.  May be this may help you


import package name;
 import org.openqa.selenium.*;
 import org.openqa.selenium.firefox.FirefoxDriver;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import org.openqa.selenium.By;
public void class allLinksOfthe Page
 WebDriver driver= new FirefoxDriver();
 driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
List<WebElement> no= driver.findElements(By.tagName("a"));
 int noflinks = no.size();
 System.out.println("no of links available in current page is" + noflinks);
 for( WebElement pagelink : no)
 String pagelinktext = pagelink.getText();
 String linkname     = pagelink.getAttribute("href");
 System.out.println("text of the link is    "+   pagelinktext);
 System.out.println("name of the link is    "+    linkname);
} catch(Exception e)


Doctor Answered on September 2, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.