BDD

CucumberJVM: 05 - More Logic with Examples:, driver.switchTo() and action.moveToElement()

Another feature file with more test data

Feature: Free CRM Create Contacts

Scenario Outline: Free CRM Login Test Scenario

Given user is already on Login Page
When title of login page is Free CRM
Then user enters "<username>" and "<password>"
Then user clicks on login button
Then user is on home page
Then user moves to new contact page
Then user enters contact details "<firstname>" and "<lastname>" and "<position>"
Then close the browser

Examples:
    | username | password | firstname | lastname | position |
    | naveenk  | test@123 | ucFirst1  | ucLast1  | manager  |
    | naveenk  | test@123 | ucFirst2  | ucLast2  | qa       |

Definitions implementation

 

CucumberJVM: 04 - Data Driven Cucumber

 

Data Driven BDD

Then user enters username and password

    @Then("^user enters username and password$")
    public void user_enters_username_and_password() {
        driver.findElement(By.xpath("//input[@name='username']")).sendKeys("naveenk");
        driver.findElement(By.name("password")).sendKeys("test@123");
    }

 

Then user enters "naveenk" and "test@123"

 

//    @Then("^user enters \"(.*)\" and \"(.*)\"$")
    @Then("^user enters \"([^\"]*)\" and \"([^\"]*)\"$")
    public void user_enters_username_and_password(String username, String password) {
        driver.findElement(By.xpath("//input[@name='username']")).sendKeys(username);
        driver.findElement(By.name("password")).sendKeys(password);
    }

@WithExamples

 

Subscribe to BDD