Reputation: 67
I am working on a framework which is already created in Selenium. It is a keyword driven framework. All keyword takes single data value as a argument. How can I pass multiple values for that single string argument in keyword. Keyword has only single string argument.
Upvotes: 2
Views: 4201
Reputation: 193706
If you want to change the signature of your methods to accept multiple keywords you can use varargs to keep backwards compatibility with your existing code.
So change:
public void someMethod(String keyword) {
//keyword is a String
}
to
public void someMethod(String... keywords) {
//keywords is a String[]
}
When someMethod
is called with a single argument keywords
is a String array of length 1.
Upvotes: 0
Reputation: 785146
If you don't have any argument other that single String then you can pass delimited string to that method e.g.
val1,val2,val3
and then inside the method use String#split to split the passed String into array or List.
PS: Just make sure that chosen delimiter doesn't appear inside the string values.
Upvotes: 3