RE: NullPointer Exception in Keyword Driven Framework

package executionEngine;

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

for (int iRow = 1; iRow <=9; iRow++) {
sActionKeyword = ExcelUtils.getCellData(iRow, Constants.Col_ActionKeyword);
actionKeywords = new ActionKeywords();
method = actionKeywords.getClass().getMethods();

sPageObject = ExcelUtils.getCellData(iRow, Constants.Col_PageObject);

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);

AishwaryMishra Default Asked on October 19, 2016 in Selenium WebDriver.
Add Comment
1 Answers

Your question is incomplete ? You haven’t specified at what line you get this error etc..  My assumption is ExcelUtils.getCellData(iRow, Constants.Col_ActionKeyword is returning null.  You can put a condition if (sActionKeyword.length() > 0) { action; }

Train Answered on October 24, 2016.
Add Comment

Your Answer

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