[b:2ndcm03u]I am using below code to make keyword driven framework but getting error like "wrong number of arguments" while executing the same.
[/b:2ndcm03u]
package com.complyadmin.test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.log4j.Logger;
import com.complyadmin.xls.read.Xls_Reader;
public class DriverScript {
public static Logger apps_logs;
//suite.xlsx
public Xls_Reader suiteXLS;
public int currentSuiteID;
public String currentTestSuite;
//current test suite
public Xls_Reader currentTestSuiteXLS;
public int currentTestCaseID;
public String currentTestCaseName;
public int currentTestStepID;
public String currentKeyword;
public int currentTestDataSetID;
public Method method[];
public Keywords keywords;
public DriverScript(){
keywords= new Keywords();
method = keywords.getClass().getMethods();
}
public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{
DriverScript test = new DriverScript();
test.start();
}
public void start() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{
apps_logs = Logger.getLogger("devpinoyLogger");
apps_logs.debug("hello");
/* 1. check the run modes of test suites
* 2. run mode of the test case in the test suite
* 3. execute keywords of the test cases serially
* 4. execute keywords as many times as
* number of data sets which are set to-Y
*/
apps_logs.debug("Initilizing suite xls");
suiteXLS = new Xls_Reader(System.getProperty("user.dir")+"//src//com//complyadmin//xls//Suite.xlsx");
for(currentSuiteID=2; currentSuiteID<=suiteXLS.getRowCount(Constants.TEST_SUITE_SHEET); currentSuiteID++ ){
apps_logs.debug(suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,Constants.Test_Suite_ID,currentSuiteID) + " -- " + suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,Constants.RUNMODE,currentSuiteID));
//String runmode = suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,"Runmode",currentSuiteID);
currentTestSuite = suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,Constants.Test_Suite_ID,currentSuiteID);
if(suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,Constants.RUNMODE,currentSuiteID).equals(Constants.Runmode_YES)){
//execute the test cases in the suite
apps_logs.debug("******exceuting the suite ******" + suiteXLS.getCellData(Constants.TEST_SUITE_SHEET,Constants.Test_Suite_ID,currentSuiteID));
currentTestSuiteXLS= new Xls_Reader(System.getProperty("user.dir")+"//src//com//complyadmin//xls//"+currentTestSuite+".xlsx");
//iterate through all the test cases in the sheet
for (currentTestCaseID=2; currentTestCaseID<=currentTestSuiteXLS.getRowCount("Test Cases");currentTestCaseID++){
apps_logs.debug(currentTestSuiteXLS.getCellData(Constants.TEST_CASES_SHEET, Constants.TCID,currentTestCaseID)+" -- "+ currentTestSuiteXLS.getCellData(Constants.TEST_CASES_SHEET, Constants.RUNMODE,currentTestCaseID));
currentTestCaseName = currentTestSuiteXLS.getCellData(Constants.TEST_CASES_SHEET, Constants.TCID,currentTestCaseID);
if(currentTestSuiteXLS.getCellData(Constants.TEST_CASES_SHEET, Constants.RUNMODE,currentTestCaseID).equals(Constants.Runmode_YES)){
apps_logs.debug("Executing the test cases-->" +currentTestCaseName);
//to check the test data is exist for the current test case
if(currentTestSuiteXLS.isSheetExist(currentTestCaseName)){
//run as many times as number of tests data sets with runmode yes
for(currentTestDataSetID=2;currentTestDataSetID<=currentTestSuiteXLS.getRowCount(currentTestCaseName);currentTestDataSetID++){
apps_logs.debug("Iteration number" +( currentTestDataSetID-1));
//checking the run mode for the current data set
if(currentTestSuiteXLS.getCellData(currentTestCaseName, Constants.RUNMODE, currentTestDataSetID).equals(Constants.Runmode_YES)){
//iterating through all keywords
executeKeywords();//multiple sets of data
}
}
}else {
//simply execute the keywords
//iterating through all keywords
executeKeywords();//no data with the test
}
}
}
}
}
}
public void executeKeywords() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
//iterating through all keywords
for(currentTestStepID=2; currentTestStepID<=currentTestSuiteXLS.getRowCount(Constants.TEST_STEPS_SHEET);currentTestStepID++){
//checking TCID
if(currentTestCaseName.equals (currentTestSuiteXLS.getCellData(Constants.TEST_STEPS_SHEET,Constants.TCID, currentTestStepID))){
currentKeyword=currentTestSuiteXLS.getCellData(Constants.TEST_STEPS_SHEET,Constants.KEYWORD, currentTestStepID);
apps_logs.debug(currentKeyword);
//code to execute the keywords as well
//reflection API
for(int i=0;i<method.length;i++){
//System.out.println(method[i].getName());
if(method[i].getName().equals(currentKeyword)){
method[i].invoke(keywords);
}
}
}
}
}
}