Question in Selenium KeyWord Driven Framework

Hi,

Toolsqa is so knowledgeable site. Thank you so much.

I have got one question in KeyWord Driven Framework link(http://toolsqa.wpengine.com/selenium-webdriver/keyword-driven-framework/java-reflection-class/)

It is giving Null pointer exception when I run the code.

Not able to access the methods of ActionKeywords class.

Request you to provide the solution for this.

Here is my code.

import java.io.File;
import java.lang.reflect.Method;

import utility.ExcelUtils;
import config.ActionKeywords;

public class DriverScript {

public static ActionKeywords actionkeywords;

public static String keyword_from_excel;

public static Method method[];

public DriverScript()  throws NoSuchMethodException, SecurityException, NullPointerException, ClassNotFoundException
{

actionkeywords = new config.ActionKeywords();
method =actionkeywords.getClass().getMethods();

 

public static void main(String[] args) throws Exception
{
File path=new File(“C:/Users/IN01972/Documents/Selenium/ToolsQA’s/Toolsqa/src/dataEngine/DataEngine.xlsx”);
String Sheetname=”Test Steps”;

ExcelUtils.setExcelSheet(path, Sheetname);
int lastrow=ExcelUtils.getLastRow(Sheetname);

System.out.println(“Methods——“+method);

for(int i=1;i<=lastrow;i++)
{
keyword_from_excel=ExcelUtils.getExcelData(i, 3);
execute_action();

}
}

private static void execute_action() throws Exception
{
//        int method_len=method.length;
//
//        System.out.println(“Method Length-=———“+method_len);
//        for(int i=0;i < method_len;i++)
//        {
//            if(method[i].getName().equals(keyword_from_excel)){
//                method[i].invoke(actionkeyword);
//                break;
//            }
//
//
//
//
//        }

Question in Selenium KeyWord Driven Framework

Default Asked on December 29, 2016 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

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