What do you mean by Scenario Outline in Cucumber?


We use the Scenario Outline keyword in the feature file in Cucumber. If a particular scenario needs to be executed with more than a set of data in multiple combinations, then we use the Scenario Outline.

The multiple data sets are represented in form of a table separated by (||) symbol under Examples keyword. Each row represents a group of data.

Example

Feature file.

Feature: Login Verification Feature
Scenario Outline: Login Verification
Given User lands on the home page
When Page title is Tutorialspoint
Then User keys in "<username>" and "<password>"
Examples:
| username | password |
| Selenium | t123     |
| Python   |pt123     |

Step Definition file with Then statement having parametrization.

Example

@Then (“^User keys in \"(.*)\” and \"(.*)\”$”)
public void user_keys(String username, String password){
   System.out.println("The username and password is : " + username
   +””+ password);
}

Updated on: 11-Jun-2020

430 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements