Cucumber

SpecFlow: C# BDD Framework Runner Example(SpecFlow.org)

SpecFlow+ Getting Started

This section guides you through the process of installing SpecFlow and SpecFlow+ Runner1 and setting up a simple project in Visual Studio. The getting started guide for SpecFlow+ Excel can be found here.

The sample project is intentionally kept very simple and consists of a basic “calculator” that adds two numbers and returns the result. You will define a test scenario to automate the testing of the calculator’s code.

This guide contains the following sections:

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 Cucumber