Я новичок в Java и Selenium, Selenium довольно забавный, я работаю над Selenium WebDriver с фреймворком TestNG Data Driven.
обратитесь к этому руководству http://software-testing-tutorials-automation.blogspot.sg/2014/07/framework-for-selenium-webdriver-report.html#comment-form
есть утилита Excel, где записываются данные, чтобы преуспеть с использованием HSSF
SuiteUtility.WriteResultUtility(FilePath, TestCaseName, "Пройдено/Не пройдено/Пропустить", DataSet+1, "PASS");
Вместо жесткого кода я планирую заменить его файлом Constant. например,
public static final String KEYWORD_PASS = "PASS";
public static final int COL_TEST_CASE_RESULT = 10; // помещаем его в столбец № 10
так что это будет как эти и станет более управляемым
SuiteUtility.WriteResultUtility(FilePath_TestResult, TestCaseName, Constant.COL_TEST_CASE_RESULT, DataSet+1, Constant.KEYWORD_PASS);
Мой вопрос заключается в том, как изменить приведенный ниже код, чтобы я мог изменить String colName на номер столбца int.
public boolean writeResult(String wsName, String colName, int rowNumber, String Result){
try{
int sheetIndex=wb.getSheetIndex(wsName);
if(sheetIndex==-1)
return false;
int colNum = retrieveNoOfCols(wsName);
int colNumber=-1;
HSSFRow Suiterow = ws.getRow(0);
for(int i=0; i<colNum; i++){
if(Suiterow.getCell(i).getStringCellValue().equals(colName.trim())){
colNumber=i;
}
}
if(colNumber==-1){
return false;
}
HSSFRow Row = ws.getRow(rowNumber);
HSSFCell cell = Row.getCell(colNumber);
if (cell == null)
cell = Row.createCell(colNumber);
cell.setCellValue(Result);
opstr = new FileOutputStream(filelocation);
wb.write(opstr);
opstr.close();
}catch(Exception e){
e.printStackTrace();
return false;
}
return true;
}