Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Data Tables in Cucumber

Category: BDD Cucumber
Scenario: Successful Login with Valid Credentials
 Given User is on Home Page
 When User Navigate to LogIn Page
 And User enters Credentials to LogIn
    | testuser_1 | Test@153 |
 Then Message displayed Login Successfully
--------------------------------------------------------------------------------
@And(""^User enters Credentials to LogIn$"")
        public void user_enters_testuser__and_Test(DataTable usercredentials) throws Throwable {

                //Write the code to handle Data Table
                List<List> data = usercredentials.raw();

                //This is to get the first data of the set (First Row + First Column)
                driver.findElement(By.id(""log"")).sendKeys(data.get(0).get(0)); 

                //This is to get the first data of the set (First Row + Second Column)
            driver.findElement(By.id(""pwd"")).sendKeys(data.get(0).get(1));

            driver.findElement(By.id(""login"")).click();
        }

Leave a Reply

Your email address will not be published. Required fields are marked *