Cucumber : Map Data Tables to Class Objects. Need Explanation how this code works? | Selenium Forum
H
Harsh Behl Posted on 14/10/2020
This is the Feature File
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
 
This is the Step Defination File
@When("^User enters Credentials to LogIn$")
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();
}
}
 
 
 
 
Query :  Can you make me understand the internal working of this code ? 

A
Ashish Replied on 16/10/2020

Credentials - Do you have this class in your framework?


H
Harsh Behl Replied on 18/10/2020

Yes Creditionals class is there.