0

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...

1 Answer 1

1

You are calling "executor.shutdown();" explicitly thats why your thread dies otherwise it would have been in the thread pool waiting for tasks. As far as your problem is concerned you need a sort of repeating tasks which can be achieved by using something like quartz schedular in which tasks can be configured to run parallely with independent repeat intervals.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.