public class ExecuteTest {
@Test
public void testLogin() throws Exception {
// TODO Auto-generated method stub
`WebDriver webdriver = new FirefoxDriver();
ReadExcelFile file = new ReadExcelFile();
ReadObject object = new ReadObject();
Properties allObjects = object.getObjectRepository();
UIOperation operation = new UIOperation(webdriver);
//Read keyword sheet
Sheet RDSheet = file.readExcel(System.getProperty("user.dir")+"\\","TestCase.xlsx" , "KeywordFramework");
//Find number of rows in excel file
int rowCount = //Loop over all the rows RDSheet.getLastRowNum()-RDSheet.getFirstRowNum();
//Create a loop over all the rows of excel file to read it
for (int i = 1; i < rowCount+1; i++) {
Row row = RDSheet.getRow(i);
//Check if the first cell contain a value, if yes, That means it is the new testcase name
if(row.getCell(0).toString().length()==0){
//Print testcase detail on console
System.out.println(row.getCell(1).toString()+"----"+ row.getCell(2).toString()+"----"+
row.getCell(3).toString()+"----"+ row.getCell(4).toString());
//Call perform function to perform operation on UI
operation.perform(allObjects, row.getCell(1).toString(), row.getCell(2).toString(),
row.getCell(3).toString(), row.getCell(4).toString());
}
else{
//Print the new testcase name when it started
System.out.println("New Testcase->"+row.getCell(0).toString() +" Started");
}
}
}
}
첫 번째 셀이 비어있을 때 널 포인터 예외가 발생합니다. 많은 블로그를 검색했지만 해결책을 찾을 수 없었습니다. 누구나 코드로 저를 도와주세요.
모든 .toString()
추가에 " "+ x.toString()
대해 값이 null이되지 않도록합니다. `
for (int i = 1; i < rowCount+1; i++) {
Row row = RDSheet.getRow(i);
//Check if the first cell contain a value, if yes, That means it is the new testcase name
if((row.getCell(0)+"").toString().length()==0){
//Print testcase detail on console
System.out.println((row.getCell(1)+"").toString()+"----"+ (row.getCell(2)+"").toString()+"----"+
(row.getCell(3)+"").toString()+"----"+ (row.getCell(4)+"").toString());
//Call perform function to perform operation on UI
//your operations
}
else{
//Print the new testcase name when it started
System.out.println("New Testcase->"+row.getCell(0).toString() +" Started");
}
}
`
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다