DriverScript and Execute_testcases

import java.io.FileInputStream;

import java.lang.reflect.Method;

import com.thoughtworks.selenium.DefaultSelenium;

import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
public class DriverScript{
static String className = null;
public static String urlpath=null;
public static int rs=1;
public static String result=null;
public static DefaultSelenium selenium=new DefaultSelenium("localhost",6666,"*iehta","http://");
public static boolean Set_Execution_sheet(String strPath) throws Exception
{
String urlpath=strPath;
FileInputStream file= new FileInputStream(urlpath);
Workbook wb=Workbook.getWorkbook(file);
Sheet sh=wb.getSheet(0);
selenium.start();
selenium.open(sh.getCell(1, 1).getContents());
selenium.windowMaximize();
return true;
}
public static boolean Execute(String str) throws Exception
{
FileInputStream file=new FileInputStream(str);
Workbook wb=Workbook.getWorkbook(file);
Sheet s=wb.getSheet(0);
for(int iRownum=1;iRownum<=s.getRows();iRownum++) { String ScreenShotPath="D:\\Framework\\Results\\"+"screenshot"+rs +".jpg"; try { if(!(s.getCell(5, iRownum).getContents()).contentEquals("")) { className=s.getCell(5, iRownum).getContents(); } else{ for(int i=iRownum;i>1;i--)
{
if(!(s.getCell(5, i).getContents()).contentEquals(""))
{
className=s.getCell(5, i).getContents();
break;
}
}
}
String functioncall = s.getCell(6, iRownum).getContents();
int inumofparameters=0;
Object ret = null;
String methodName = functioncall.substring(0,functioncall.indexOf("("));
String strparameters = functioncall.substring(functioncall.indexOf("(")+1,functioncall.indexOf(")"));
String strparameterslist[]=strparameters.split(",");
inumofparameters= strparameterslist.length;
selenium.captureScreenshot(ScreenShotPath);
if(strparameters.length()==0){
inumofparameters=0;
}
Class c = Class.forName(className);
if(inumofparameters!=0){
Class cParameters[]=new Class[inumofparameters];
for(int temp=0;temp {
cParameters[temp]= String.class;
}
Method m = c.getMethod(methodName,cParameters );
Object ob = c.newInstance();
Object arglist[] = new Object[inumofparameters];
for(int iparameternum=0;iparameternum {
arglist[iparameternum] = new String(strparameterslist[iparameternum]);
}
ret = m.invoke(ob,arglist);
}else
{
Method m = c.getMethod(methodName,null);
Object ob = c.newInstance();
ret = m.invoke(ob,null);
System.out.println("return value:"+ ret);
}
rs++;
}catch(Exception e){
selenium.captureScreenshot(ScreenShotPath);
e.printStackTrace();
}
}

return true;

}
}
-----------
public class Execute_Testcases Extends DriverScript {
public static void main(String[] args) throws Exception
{
DriverScript.Set_Execution_sheet("D:\\Framework\\Environment\\url.xls");
DriverScript.Execute("D:\\Framework\\MainScript\\testcases.xls");

}

}