Java Null Pointer Exception on running the test case in seleniumn..Can i get a solution for this please

11 views
Skip to first unread message

Sandhya M

unread,
Oct 1, 2020, 3:45:31 AM10/1/20
to testng-users
-1

Iam getting Java Null Pointer Exception...using POM and Data Provider to read the value from Excel ..all the values are proper in the Excel. Below is the Code:

Page:

public void CreatenewCompany(String names,String web,String add,String cities,String stat,String zip,String valuecountry,String phonecountry, String socialselect,String ind,String pvalue,String img) { elementutils.waitforElementPresent(name); elementutils.doSendKeys(name, names); elementutils.waitforElementPresent(website); elementutils.doSendKeys(website, web); elementutils.waitforElementPresent(Fetchbutton); elementutils.doclick(Fetchbutton); elementutils.waitforElementPresent(address); elementutils.doSendKeys(address, add); elementutils.waitforclickingElement(city); elementutils.doSendKeys(city, cities); elementutils.waitforclickingElement(state); elementutils.doSendKeys(state, stat); elementutils.waitforElementPresent(zipcode); elementutils.doSendKeys(zipcode, zip); elementutils.waitforElementPresent(country); elementutils.doclick(country); elementutils.selectvaluefromdropdown(countryvalueselect, valuecountry); elementutils.waitforclickingElement(PhoneCountrydropdown); elementutils.doclick(PhoneCountrydropdown); elementutils.selectvaluefromdropdown(phonecountryvalueselect, phonecountry); elementutils.waitforclickingElement(socialchannelsdropdown); elementutils.doclick(socialchannelsdropdown); elementutils.selectvaluefromdropdown(socicalchannelselectval, socialselect); elementutils.doWaitforElement(twitterhandletext); elementutils.doclick(twitterhandletext); elementutils.waitforElementPresent(addbutton); elementutils.doclick(addbutton); elementutils.selectvaluefromdropdown(priorityvalue, pvalue);

 elementutils.doWaitforElement(industry); elementutils.doSendKeys(industry, ind); elementutils.doWaitforElement(priority); elementutils.doclick(priority); elementutils.waitforclickingElement(image); elementutils.doclick(image); elementutils.doSendKeys(image, img); }

}


                                                            Test Class

@DataProvider() public Object[][] getNewCompInfo() { Object[][] data = ExcelUtil.getTestData(AppConstants.New_Company_Sheet_Name); return data;

} @Test(priority=3,dataProvider="getNewCompInfo") public void CreatenewCompany(String name,String website,String address,String city,String state,String zipcode,String country,String phone,String socialchannel,String twitterhandle,String priority,String image) { companies.CreatenewCompany(name, website, address, city, state, zipcode, country, phone, socialchannel, twitterhandle, priority, image); }

}


                                             StackTrace

Caused by: java.lang.NullPointerException at com.qa.FreeCRMPRO.Utils.ExcelUtil.getTestData(ExcelUtil.java:41) at com.qa.FreeCRMPRO.test.CompaniesPageTest.getNewCompInfo(CompaniesPageTest.java:58) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74) at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45) ... 22 more  


 Excel showing Error in this line:data[i][k] = sheet.getRow(i+1).getCell(k).toString(); Excel values: 




⇜Krishnan Mahadevan⇝

unread,
Oct 1, 2020, 3:49:49 AM10/1/20
to testng-users
Your issue has got nothing to do with TestNG.
The error is coming from your test code when you are trying to parse/read the excel spreadsheet (This method in specific ExcelUtil.getTestData)

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/7d164d2c-ae4c-47e2-b53e-6ecc2b672038n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages