Pages

Thursday, 15 December 2011

AUTOMATE MULTPLE URLS USING DATADRIVEN


Here is the code to Automate Multile URLS using DataDriven............

package qtt.selenium;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.server.*;

public class MultiURL {
   public Selenium selenium;
   SeleniumServer ss;
   @Before
   public void setUp() throws Exception {
   ss = new SeleniumServer();
   selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://");
   ss.start();
   selenium.start();
   }
   @Test
   public void testMultiURL() throws Exception {
   // Read data from excel sheet
   FileInputStream fi = new FileInputStream(
   "E:\\MIDHUN\\TESTDATA\\URL.xls");
   Workbook w = Workbook.getWorkbook(fi);
   Sheet s = w.getSheet(0);
   String a[] = new String[s.getRows()];
   for (int i = 1; i < s.getRows(); i++)
   {
   String str= s.getCell(0, i).getContents();
   selenium.open(str);
   selenium.windowMaximize();
   Thread.sleep(10000);
   }
  
   }
   @After
   public void tearDown() throws Exception {
   selenium.stop();
   ss.stop();
   }
}

Examle:URL.xls


No comments:

Post a Comment