What would be the best way to write selenium and testng automation scripts for field level validation tor more than 100 fields

Viewed 31

I have more than 50 fields present in a single page.I need to do a field level validation like is it visible,editable,mandatory,spelling of the label,max limit for text fields and field type like dropdown/Numeric/Alphanumeric/Checkbox. Then What would be the best and simple practice to do all these.

1 Answers

You can use data provider for validation. Only you have to apply logic which error message to verify by applying if else statement. Below is example of the Login with multiple combinations.

@DataProvider(name="Loginfn")
public Object[][] LoginDataProvider() throws Exception
{
  return getDataProviderData("Login");
}

@Test(dataProvider="Loginfn")
public void Login(String username, String password, String assertDisplayed) throws Exception
{
  Locator lc = objectRepository.get("assertDisplayed");
  LoginPageMethods loginm = new LoginPageMethods();
  loginm.LoginM(username,password);
  takeScreenShot();
  Assertion.assertDisplyed(lc);
}
Related