RE: Null Pointer exception in Keyword Driven Framework

hi Lakshay & Team,

Thanks for this wonderful site, Like me, you are helping lot of people out there. God bless you all.

I am getting same error, after debugging , error throws in execute_Actions() method, as you told sActionKeyword, it has a value openBrowser but when it enters the execute_Action method Method method.length will be null.

This the code


package executionEngine;
import java.lang.reflect.Method;

import config.ActionKeywords;

import utility.ExcelUtils;
public class DriverScript {
public static ActionKeywords actionKeywords;

public static String sActionKeyword;

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 sPath = “..\\src\\dataEngine\\DataEngine.xlsx”;

ExcelUtils.setExcelFile(sPath, “Test Steps”);

for (int iRow=1; iRow<=9; iRow++){

sActionKeyword = ExcelUtils.getCellData(iRow, 3);



private static void execute_Actions() throws Exception {

for (int i=0; i<method.length;i++){

if (method[i].getName().equals(sActionKeyword)){






Add Comment
5 Answers

The reason you are getting null pointer exception in your original code is that, you are not creating the object of DriverScript class. Once you create an object the constructor will get invoked and you won’t get null pointer exception.


Train Answered on March 28, 2015.
Add Comment

Your Answer

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