Equivalent of Execute(vbScript) statement in Java
I have a framework in QTP where I navigate function wise by picking the function name from excel sheet. So the command that helps me in doing so is..
Execute “strResult = “&strFunctionName&”()”
Based on the strResult value i.e True or False, I decide whether the function has passed or failed.
What is the equivalent of this Execute or Eval command of vbscript in Java?
In Java we dont have a eval function. However we can do the same thing using class loaders. I would suggest you read the driver script class here
a summary of what you want do do can be divided like this
1. Get all the methods from a class like this, assuming all the methods are implemented inside a class called ActionClass
Method method = ActionClass.getClass().getMethods();
2. Check the name of the methods in class against the names in excel
method[i].getName().equals(<Method name from excel>);
3. Put above check in if condition and you can execute the method like this
method[i].invoke(Arguments to the method)
Just try it out and let us know about the results.