my feature file is like:
Given User is on Home Page
When User Navigate to LogIn Page
And User enters Credentials to LogIn
| Username | Password |
| testuser_1 | Test@153 |
| testuser_2 | Test@154 |
Then Message displayed Login Successfully
Step Definition is:
public void user_enters_testuser_and_Test(List<Credentials> usercredentials) throws Throwable {
//Write the code to handle Data Table
for (Credentials credentials : usercredentials) {
driver.findElement(By.id("log")).sendKeys(credentials.getUsername());
driver.findElement(By.id("pwd")).sendKeys(credentials.getPassword());
driver.findElement(By.id("login")).click();
}
}
Here is the customized Object argument:
public class Credentials {
private String username;
private String password;
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
}
when I run the code I always got this error:
cucumber.runtime.CucumberException: Could not convert arguments for step [^User enters Credentials to LogIn$] defined at 'stepDefinitions.ConsumerServiceEnquiry.ConsumerSteps.user_enters_testuser_and_Test(Credentials>) in file:/C:/Users/jxz36/eclipse-workspace/SDBCucumberTestng/bin/'.
I have searched everywhere, and see a lot of similar example. so I think it must be some basic error or missing configuration. Please can anybody help me out of this? Much appreciated!