Actually, i'm trying to run the selenium framework for web application testing purpose. I'm able to run the framework using excel sheets data as input. when i'm trying to run that with different inputs so that, my framework should run with different inputs simultaneously in local system. I think this can be done in Threadpool executor. I can able to initiate the two threads for two set of inputs. But while the second thread starts, first one gets died.But while running with single input, it is working good. I don't know what is missing in my code. I have given the code below, Please have a look into that friends,
Driverscript.java
public static void main (String[] args) throws ReflectiveOperationException, Exception {
String configPath =args[0];
DriverScript Test = new DriverScript(configPath);
//Test.start(configPath);
String mapFile=CONFIG.getProperty("Application");
Xls_Reader ApplicationXLS=new Xls_Reader(mapFile);
int rowCount=ApplicationXLS.getRowCount(Constants.TEST_APP_SHEET);
ExecutorService executor =Executors.newFixedThreadPool(rowCount);
for(int CurrentApplicationID=2;CurrentApplicationID<=ApplicationXLS.getRowCount(Constants.TEST_APP_SHEET);CurrentApplicationID++){
if(ApplicationXLS.getCellData(Constants.TEST_APP_SHEET, Constants.TEST_APP_RUNMODE,CurrentApplicationID).equalsIgnoreCase("Permitted")){
SuitePath=ApplicationXLS.getCellData(Constants.TEST_APP_SHEET, Constants.TEST_APP_SUITEPATH,CurrentApplicationID);
ObjectRepo=ApplicationXLS.getCellData(Constants.TEST_APP_SHEET, Constants.TEST_APP_OBJECT_REPOSITORY,CurrentApplicationID);
new ObjectRepLocator(ObjectRepo);
SuiteXLS = new Xls_Reader(SuitePath);
CurrentSuiteSheet=ApplicationXLS.getCellData(Constants.TEST_APP_SHEET, Constants.TEST_APP_ID, CurrentApplicationID);
Runnable worker=new ThreadScheduler(SuiteXLS,CurrentSuiteSheet);
Thread.currentThread().join(3000);
executor.execute(worker);
}
}
executor.shutdown();
if(executor.isTerminated())
new ReportUtil(configPath,SuitePath);
}
public static void start(Xls_Reader SuiteXLS,String CurrentSuiteSheet) throws ReflectiveOperationException, IllegalArgumentException, Exception {
<<----content of the Start() function---->>
}
ThreadScheduler.java
public class ThreadScheduler implements Runnable {
public static Xls_Reader SuiteXLS;
public static String currentSuiteSheet;
public static String currentTestSuitePath;
ThreadScheduler(Xls_Reader SuiteXLS, String CurrentSuiteSheet){
this.SuiteXLS=SuiteXLS;
this.currentSuiteSheet=CurrentSuiteSheet;
// this.currentTestSuitePath=CurrentTestSuitePath;
}
@Override
public void run(){
try{
System.out.println(Thread.currentThread().getName());
System.out.println(Thread.currentThread().getState());
System.out.println(SuiteXLS);
System.out.println(currentSuiteSheet);
DriverScript.start(SuiteXLS,currentSuiteSheet);
System.out.println("End of "+ Thread.currentThread().getName());
}
catch(Exception e){
e.printStackTrace();
}
}
I'm using Eclispe juno. This framework is for Selenium automation. Thanks in advance friends...