Below is the Error:
java.lang.RuntimeException: java.lang.NullPointerException
at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:49)
at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131)
at org.testng.internal.Parameters.handleParameters(Parameters.java:706)
at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:49)
at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:37)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:924)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.NullPointerException
at com.qa.FreeCRMPRO.Utils.ExcelUtil.getTestData(ExcelUtil.java:38)
at com.qa.FreeCRMPRO.test.DealsPageTest.getEventInfo(DealsPageTest.java:96)
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 Util:
public class ExcelUtil {
public static Workbook book;
public static Sheet sheet;
public static String TESTDATA_SHEET_PATH = "D:\\Excel\\FreeCRMPROCompanies.xlsx";
public static Object [][] getTestData(String sheetName)
{
try {
FileInputStream ip = new FileInputStream(TESTDATA_SHEET_PATH);
try {
book= WorkbookFactory.create(ip);
} catch (InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sheet= book.getSheet(sheetName);
Object data[][] = new Object[sheet.getLastRowNum()][sheet.getRow(0).getLastCellNum()];
for(int i=0;i<sheet.getLastRowNum();i++)
{
for(int k =0;k<sheet.getRow(0).getLastCellNum();k++)
{
data[i][k] = sheet.getRow(i+1).getCell(k).toString();
}
}
return data;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("Not able to fetch the values from the Excel");
}
Page :
public void EditEvent(String newtitle,String calender,String addnewcalender,String calender1,
String startdates,String enddates,String catvalue,String desc,
String loca,String dealsselection,String alertbefore,
String alertviadrop,String remindtime,String assignedtoselect,String intervalvalue,String dayvalue,
String seldate)
{
try {
elementutils.waitforElementPresent(AddEventbutton);
elementutils.doclick(AddEventbutton);
elementutils.waitforElementPresent(eventtitle);
elementutils.doSendKeys(eventtitle, newtitle);
elementutils.waitforElementPresent(Calenderdropdownclick);
elementutils.doclick(Calenderdropdownclick);
elementutils.selectvaluefromdropdown(calendervalueselection, calender);
elementutils.waitforElementPresent(addnewCalenderName);
elementutils.doSendKeys(addnewCalenderName, addnewcalender);
elementutils.waitforclickingElement(savecalendername);
elementutils.doclick(savecalendername);
elementutils.selectvaluefromdropdown(calendervalueselection, calender1);
elementutils.waitforclickingElement(Startdateclick);
elementutils.clickonCalender(startdatecolumselection, startdates);
elementutils.waitforElementPresent(enddateclick);
elementutils.doclick(enddateclick);
elementutils.waitforclickingElement(enddatecolumnselection);
elementutils.clickonCalender(enddatecolumnselection, enddates);
elementutils.waitforclickingElement(categoryEvent);
elementutils.doclick(categoryEvent);
elementutils.selectvaluefromdropdown(categoryEventvalue, catvalue);
elementutils.waitforElementPresent(description);
elementutils.doSendKeys(description, desc);
elementutils.waitforElementPresent(location);
elementutils.doSendKeys(location, loca);
elementutils.waitforElementPresent(alldaytoggle);
elementutils.doclick(alldaytoggle);
elementutils.waitforclickingElement(DealSearchicon);
elementutils.doclick(DealSearchicon);
elementutils.selectvaluefromdropdown(dealsdropdownselection, dealsselection);
elementutils.waitforElementPresent(Alertbefore);
elementutils.doclick(Alertbefore);
elementutils.selectvaluefromdropdown(Alertbeforevalue, alertbefore);
elementutils.waitforElementPresent(Alertviadropdown);
elementutils.doclick(Alertviadropdown);
elementutils.selectvaluefromdropdown(Alertviadropdownvalue, alertviadrop);
elementutils.waitforElementPresent(remindertime);
elementutils.doSendKeys(remindertime, remindtime);
elementutils.waitforElementPresent(Assignedto);
elementutils.doclick(Assignedto);
elementutils.selectvaluefromdropdown(Assignedtovalueselection, assignedtoselect);
elementutils.waitforclickingElement(Recurrenceset);
elementutils.doclick(Recurrenceset);
elementutils.waitforElementPresent(intervaldropdownlick);
elementutils.doclick(intervaldropdownlick);
elementutils.selectvaluefromdropdown(intervalvalueselect, intervalvalue);
elementutils.waitforElementPresent(days);
elementutils.doclick(days);
elementutils.selectvaluefromdropdown(daysvalueselect, dayvalue);
elementutils.waitforElementPresent(Endat);
elementutils.doclick(Endat);
elementutils.waitforElementPresent(selectdate);
elementutils.clickonCalender(selectdate, seldate);
elementutils.waitforElementPresent(setbutton);
elementutils.doclick(setbutton);
elementutils.waitforElementPresent(saveevent);
elementutils.doclick(saveevent);
}catch(Exception e)
{
System.out.println("Element is not clickable");
}
}
Test Page:
@DataProvider
public Object[][] EditDealsInfo()
{
Object data[][] = ExcelUtil.getTestData(AppConstants.Edit_Deals_Sheet_Name);
return data;
}
@Test(priority=4,dataProvider="EditDealsInfo",enabled=true)
public void editdetails(String title)
{
dealspage.EditDealsInfo(title);
}
Site: ui.cogmento.com
Excel :
eventstitle |
calendervalues |
calendername |
selectcalendersvalues |
startdates |
enddates |
categorys |
descriptions |
locations |
deals |
alertbefores |
alertvias |
remindertimes |
assignedtos |
intervals |
days |
finalenddates |
newevent |
New Calendar |
test |
test |
20/09/2020 |
20/09/2020 |
Critical |
new |
us |
sam |
1 Hour |
SMS |
12 |
Sandhyaseleniumn s |
Monthly |
Friday |
20/09/2020
|