Am using java reflection, Here am using object org.openqa.selenium.remote.RemoteWebElement, to call method called sendKeys. This method will accept characterSequence Array as a parameter type, so am passing characterSequence[] as parameter . Using classname.getMethod(sendKeys, characterSequence[]) I can get the methodname. But when this method is innvoked in runtime passing array of characterSequences[] as argument it throws
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.thbs.manager.Reflections.callSeleniumCommand(Reflections.java:115)
at com.google.manager.Testing.doTestExecution(Testing.java:105)
at com.google.manager.Testing.main(Testing.java:22)
Could not post the entire code,but posted the code which throws error
objToCallWith = org.openqa.selenium.remote.RemoteWebElement
cls = objToCallWith.getClass();
methodName = sendKeys
params = CharSequence[].class
// send keys method accept only CharSequence[]
myMethod = cls.getMethod(methodName, params);
// able to getMethod
args = new CharSequence[]{'a','b'}
// Here Exception java.lang.IllegalArgumentException: argument type mismatch
myMethod.invoke(objToCallWith,args);
Aucun commentaire:
Enregistrer un commentaire