I am getting this error NullPointerException against the code line

I am getting this error against the code present at this site http://www.toolsqa.com/selenium-webdriver/keyword-driven-framework/object-repository/

I am getting this error against the code line as follows:
line 82:  for(int i=0;i<method.length;i++)
line 55: execute_Actions();

Issue is with the public static Method method[]; 

Exception in thread “main” java.lang.NullPointerException
at executionEngine.DriverScript.execute_Actions(DriverScript.java:82)
at executionEngine.DriverScript.main(DriverScript.java:55)

Please assist as soon as possible m stuck from last couple of days on this.

sabrol Default Asked on November 18, 2015 in Selenium WebDriver.

can you please paste your complete code here..?

on November 18, 2015.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package executionEngine;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.Properties;
import config.ActionKeywords;
import config.Constants;
import utility.ExcelUtils;
public class DriverScript {
public static Properties OR;
public static ActionKeywords actionKeywords;
public static String sActionKeyword;
public static String sPageObject;
public static Method method[];
public DriverScript() throws NoSuchMethodException, SecurityException{
actionKeywords = new ActionKeywords();
method = actionKeywords.getClass().getMethods();
}
    public static void main(String[] args) throws Exception {
     String Path_DataEngine = Constants.Path_TestData;  
     ExcelUtils.setExcelFile(Path_DataEngine, Constants.Sheet_TestSteps);
//Declaring String variable for storing Object Repository path
     String Path_OR = Constants.Path_OR;
//Creating file system object for Object Repository text/property file
FileInputStream fs = new FileInputStream(Path_OR);
//Creating an Object of properties
OR= new Properties(System.getProperties());
//Loading all the properties from Object Repository property file in to OR object
OR.load(fs);
     for (int iRow=1;iRow<=9;iRow++){
     sActionKeyword = ExcelUtils.getCellData(iRow, Constants.Col_ActionKeyword);
     sPageObject = ExcelUtils.getCellData(iRow, Constants.Col_PageObject);
     execute_Actions();
     }
     }
     private static void execute_Actions() throws Exception {
for(int i=0;i<method.length;i++){
if(method[i].getName().equals(sActionKeyword)){
//This is to execute the method or invoking the method
//Passing ‘Page Object’ name and ‘Action Keyword’ as Arguments to this method
method[i].invoke(actionKeywords,sPageObject);
break;
}
}
}
}
on November 18, 2015.

Hi Ankit,

In this case I am getting NULL POINTER ERROR at line no. 32 & 36.

on November 18, 2015.
Add Comment
1 Answer(s)

Hi Ankit,

Thankyou for the reply.
Request you to refer the code present at this site: http://www.toolsqa.com/selenium-webdriver/keyword-driven-framework/object-repository/

In the above link please refer Class=> Driver Script present at bottom.

Thanking you in advance.

sabrol Default Answered on November 18, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.