http://www.technicalpage.net/search/label/SQL

Data Driven in BDD framework, Parametarization in cucumber


Data Driven in BDD framework, 
Parametarization in cucumber
Not using example

Using example

Using tables

Not using example ,ie, data is provided from feature file:

For example , below is the normal hardcoded step:
In feature file:
And user enters userID and PWD
In step definition:
@And(“^user enters userID and PWD$”)
Public void enterCredentials(){
Driver.findElement(By.xpath).sendKeys(“raviKarki”);
Driver.findElement(By.xpath).sendKeys(“test123”);
}

Above code can be changed like below:
Now, we give the hard coded userID and password in feature file itself.
And user enters “ravikarki” and “test123”
And in step definition:
@And(“^user enters \”(.*)\” and \”(.*)\”$”)//you can also write \”([^\”]*)\”---these are called regular expression
Public void enterCredentials(String uid, String pwd){
Driver.findElement(By.xpath).sendKeys(uid);
Driver.findElement(By.xpath).sendKeys(pwd);
}

 Using example:
DataDriven in BDD with example keyword:
In feature file:
Scenario Outline: ScenarioName or Description #Outline is necessary with examples data driven framework.
Given step…
And user enters “” and “
And click login
...
And Last Step

# After last step
Examples:
| uid | pwd |
| ramkarki | tst123 |
| haribadur | hrk123 |
Now in step definition:
@And(“^user enters \”(.*)\” and \”(.*)\”$”)
Public void enterCredentials(String uid, String pwd){
Driver.findElement(By.xpath).sendKeys(uid);
Driver.findElement(By.xpath).sendKeys(pwd);
}

In Progress...

No comments:

Post a Comment