java - Null Pointer Exception while reading from excel? -


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 on rows rdsheet.getlastrownum()-rdsheet.getfirstrownum();     //create loop on rows of excel file read     (int = 1; < rowcount+1; i++) {         row row = rdsheet.getrow(i);         //check if first cell contain value, if yes, means 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 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 new testcase name when started             system.out.println("new testcase->"+row.getcell(0).tostring() +" started");             } } } } 

getting null pointer exception when first cell empty. have searched many blogs couldn't find solution can please me code.

for every .tostring() add " "+ x.tostring() it, value doesnt become null. `

for (int = 1; < rowcount+1; i++) {         row row = rdsheet.getrow(i);         //check if first cell contain value, if yes, means 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 perform operation on ui         //your operations      } else{  //print new testcase name when started             system.out.println("new testcase->"+row.getcell(0).tostring() +" started");             } }   ` 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -