Hi Hubert,
Thank you for the response. I'm new to Selenium so excuse my ignorance on some practices.
I'm testing a web interface. I hardcode my locators, login details, expected messages, etc. in xml and then call them in dataprovider. Some of them are reused when passed to dataproviders. We don't have build system yet and all test are manual. I want to make my life easier :)
My 2nd question is, is there a way to pass a parameter to dataprovider function? I have 5 dataprovider for my 5 testcase and the code is the same, the difference is just on the string I passed. See example below.
@DataProvider(name="blankuserblankpass")
public static Object[][] blankuserblankpass(ITestContext context) {
String uiString = ""
+ "url.landingpage,"
+ "url.login,"
+ "title.landingpage,"
+ "button.landingpage.login.locator,"
+ "textfield.login.username.locator,"
+ "text.login.username.blank,"
+ "textfield.login.password.locator,"
+ "text.login.password.blank,"
+ "button.login.login.locator,"
+ "url.login.fail,"
+ "text.loginfailed.failedmessage.blank";
String[] uiObj = uiString.split(",");
HashMap stringList = lib.genHashMap(uiObj, context);
Object[][] result = new Object[][] {{ stringList }};
return result;
}
First option is to use condition using method name but the function would become too big.
2nd option is to hardcode the strings to a parameter name (but that would then increase my already big parameters in testng.xml) and use the first option to call it.
There is no wrong/right answer. Just let me know what you think. Many thanks for your suggestion.
Br,
Keith