how to have functions which has more than 2 number of arguments in Keyword driven framework
I am trying to create a Keyword driven framework where in there are functions with variable number of parameters.
eg: Drag_and_drop(String sourceElement,String destinationElement)
As per the (http://www.toolsqa.com/selenium-webdriver/keyword-driven-framework/object-repository/)link it says the functions should have same number and type of arguments.
Note: If you see carefully, object argument is passed in every method, even if it is not required in the method, such as ‘closeBrowser()’. This is the mandatory condition of the reflection class that all the methods will have same arguments, even if the argument is not used in some methods.
Please let me know how to incorporate such functions which may vary with different number and type of arguments
Thanks in advance.
This is very important question. Usually the demo on toolsqa works with only one parameter, however you can pass any number of parameters. However, this means that all the key methods will have same number of parameters.
Solution: It is always better to pack all the variables in a structure or a class and then pass the class as one parameter to all the key word methods. In the method only use the values that you desire. Try a List of key value pair or a custom class.