RefelectionApi in module 6 of selenium | Selenium Forum
M
Posted on 05/05/2016
I'm not getting how to use RefelectionApi.
i run your example by in my program some error .
Error is
""Exception in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class""
Code is
/*
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test {


public static void main (String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
String x="SampleTest";
Method method=Test.class.getMethod(x, String.class);
method.invoke(method, "hello");

}
public void SampleTest(String x){
System.out.println("In Sample Methode :"+x);
}

}*/

M
Replied on 05/05/2016

use this


[quote:3nbeijbj]package com.soapuitutorial.propertie;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class reflection_api {

public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
String x = "SampleTest";
Method method = reflection_api.class.getMethod(x, String.class);
method.invoke(method, "hello");

}

public static void SampleTest(String x) {
System.out.println("In Sample Methode :" + x);
}

}[/quote:3nbeijbj]