how read the URL from Excel sheet using selenium webdriver

it is necessary tom read all the rows in the excel sheet and open it

Add Comment
  • 2 Answer(s)

    Hi balajinatarajan,

    CanĀ  you give us the code that you have written till now? We can tell you the problem you have. Its quite hard to give a code that will suite your need.

    Thanks
    Virender

    Professor Answered on September 4, 2014.
    Add Comment

    publicvoid f() throws Throwable, IOException {

    FileInputStream fi = new FileInputStream(“D:\\sites.xls”);

    WebDriver driver = new FirefoxDriver();

    Workbook wb = Workbook.getWorkbook(fi);

    Sheet s = wb.getSheet(0);

    system,out.println(s.getRows());

    //driver.getURl();

    {

    /*FileInputStream fi = new FileInputStream(“D:\\data.xls”);

    Workbook w = Workbook.getWorkbook(fi);

    s = w.getSheet();*/

    driver.get(“APPUrl”);

     

    for(int row=1; row <=s.getRows();row++)

    {

    String Urllist = s.getCell(0, row).getContents();

    1. out.println(“Urllist”+ Urllist);

    java.util.List<WebElement> linkElements = driver.findElements(By.tagName(“a”));

     

    String[] linkTexts = new String[linkElements.size()];

    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

     

    int j = 0;

    for (WebElement e : linkElements)

    {

    linkTexts[j] = e.getText();

    j++;

    }

     

    //test each link

    for (String t : linkTexts)

    {

    if (t != null && !t.isEmpty())

    {

    driver.findElement(By.linkText(t)).click();

    String title;

    title=driver.getTitle();

    if(title.contains(“404”))

    {

    1. out.println(t+” the link is not working”);

    }

    else{

    1. out.println(“\”” + t + “\””

    + ” is working.”);

    }

    Train Answered on September 8, 2014.
    Add Comment
  • Your Answer

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