Selenium Java - TestNG Integration
You want to test a login form with multiple username and password combinations using a DataProvider. Which approach correctly handles this scenario to avoid test failures when a password is empty or null?
@DataProvider(name = "loginData")
public Object[][] loginData() {
return new Object[][] {
{"user1", "pass1"},
{"user2", ""},
{"user3", null}
};
}
@Test(dataProvider = "loginData")
public void testLogin(String username, String password) {
// Test logic here
}