RunMode | Selenium Forum
M
Posted on 16/12/2015
Hi Ashish , i am having problem with running the test, testNg is skipping the tests, even when i set the RunMode to YES in Excel file , it skips the tests. also when i run the test more each browser opens four times in framework module 21.
kindly assist me with this issue.
Thank you,

M
Replied on 16/12/2015

post the code for isSuiteRunnable() and isTestcaseRunnable()


M
Replied on 16/12/2015

public static boolean isSuiteRunnable(String suiteName) {
Xls_Reader xls=new Xls_Reader(Constants.TESTSUITE_XLS_PATH);
int rows=xls.getRowCount(Constants.TESTSUITE_SHEET);
for(int rNum=2;rNum<=rows;rNum++){
String testSuiteName=xls.getCellData(Constants.TESTSUITE_SHEET, Constants.SUITENAME_COL, rNum);
if(testSuiteName.toLowerCase().equals(suiteName.toLowerCase())){

String runMode=xls.getCellData(Constants.TESTSUITE_SHEET, Constants.RUNMODE_COL, rNum);
if(runMode.equals(Constants.RUNMODE_YES))
return true;
else
return false;

}

}
return false;

}

public static boolean isTestCaseRunnable(String testCaseName,Xls_Reader xls) {
int rows=xls.getColumnCount(Constants.TESTCASES_SHEET);
for(int rNum=2;rNum<=rows;rNum++){
String testName=xls.getCellData(Constants.TESTCASES_SHEET, Constants.TESTCASE_COL, rNum);
if(testName.toLowerCase().equals(testCaseName.toLowerCase())){
String runMode=xls.getCellData(Constants.TESTCASES_SHEET, Constants.RUNMODE_COL, rNum);
if(runMode.equals(Constants.RUNMODE_YES))
return true;
else
return false;
}
}
return false;


}


M
Replied on 16/12/2015

[quote="rkhan6310@gmail.com":fnzv2gok]public static boolean isSuiteRunnable(String suiteName) {
Xls_Reader xls=new Xls_Reader(Constants.TESTSUITE_XLS_PATH);
int [color=#FF0000:fnzv2gok]rows=xls.getRowCount(Constants.TESTSUITE_SHEET)[/color:fnzv2gok];
for(int [color=#FF0000:fnzv2gok]rNum=2[/color:fnzv2gok];rNum<=rows;rNum++){
String testSuiteName=xls.getCellData(Constants.TESTSUITE_SHEET, Constants.SUITENAME_COL, rNum);
if(testSuiteName.toLowerCase().equals(suiteName.toLowerCase())){

String runMode=xls.getCellData(Constants.TESTSUITE_SHEET, Constants.RUNMODE_COL, rNum);
if(runMode.equals(Constants.RUNMODE_YES))
return true;
else
return false;

}

}
return false;

}

public static boolean isTestCaseRunnable(String testCaseName,Xls_Reader xls) {
int [color=#FF0000:fnzv2gok]rows=xls.getColumnCount(Constants.TESTCASES_SHEET)[/color:fnzv2gok];
for(int [color=#FF0000:fnzv2gok]rNum=2[/color:fnzv2gok];rNum<=rows;rNum++){
String testName=xls.getCellData(Constants.TESTCASES_SHEET, Constants.TESTCASE_COL, rNum);
if(testName.toLowerCase().equals(testCaseName.toLowerCase())){
String runMode=xls.getCellData(Constants.TESTCASES_SHEET, Constants.RUNMODE_COL, rNum);
if(runMode.equals(Constants.RUNMODE_YES))
return true;
else
return false;
}
}
return false;


}[/quote:fnzv2gok]


for loops does not executes because [color=#FF0000:fnzv2gok]rNum>rows[/color:fnzv2gok] and it returns false.

please check the values or [color=#FF0000:fnzv2gok]rows and rNum [/color:fnzv2gok]. are those variable [color=#FF0000:fnzv2gok]rows [/color:fnzv2gok]picking values from xls sheet or not.


M
Replied on 16/12/2015

i tried it but same problem has accured , i am sending you the project please take a look , it might be problem with other code.
Thank you.


M
Replied on 16/12/2015

send me the excell sheet.


M
Replied on 17/12/2015

excel sheets are attached .Thanks


M
Replied on 17/12/2015

[quote:819i4d2h]public static boolean isTestCaseRunnable(String testCaseName,Xls_Reader xls) {
int [color=#FF0000:819i4d2h]rows=xls.getColumnCount(Constants.TESTCASES_SHEET);
[/color:819i4d2h]for(int rNum=2;rNum<=rows;rNum++){
String testName=xls.getCellData(Constants.TESTCASES_SHEET, Constants.TESTCASE_COL, rNum);
if(testName.toLowerCase().equals(testCaseName.toLowerCase())){
String runMode=xls.getCellData(Constants.TESTCASES_SHEET, Constants.RUNMODE_COL, rNum);
if(runMode.equals(Constants.RUNMODE_YES))
return true;
else
return false;
}
}
return false;


}

[/quote:819i4d2h]

you're getting column count get [color=#FF0000:819i4d2h]getRowCount(SheetName)[/color:819i4d2h]


M
Replied on 18/12/2015

Thank you for your help!