This is used when we need to pass multiple values to the same step definition (.py) file.
Below are the steps to create scenario outline.
1. We need to define a term as “outline” beside the scenario name in the feature file.
2. Under Scenario after steps we need to define “Example:” and below this we need to define variable names and values as shown below.
Examples: | emailid |password|Verify Sc| | student@gmail.com| S1234 | SS | | Teacher@gmail.com| T1234 | TS |
3. In steps we need to write the parameter name which we defined under “Example:” in “< >” as When Enter <emailid> UserID
When Enter <emailid> UserID When Enter <password> password Then Verify <Verify Sc> Screen
We can define the required number of parameters side by side along with values.
Example: Here we are passing different login details to verify whether it is a Student or Teacher login to the same step definition file.
login_screen.feature
# This is a Feature file Feature: Fill the Contact Form Scenario Outline: User Login credentials Given Launch the App and Click on Login Button When Enter <emailid> UserID When Enter <password> password Then Verify <Verify Sc> Screen Examples: | emailid |password|Verify Sc| | student@gmail.com| S1234 | SS | | Teacher@gmail.com| T1234 | TS |
LoginScreen.py
from behave import given, when, then @given("Launch the App and Click on Login Button") def methodOne(context): print("L1 - Launching the App") @when("Enter {emailid} UserID") def methodTwo(context,emailid): print("L2 - Enter the UserID in Login Screen {} ".format(emailid)) @when("Enter {pasw} password") def methodThree(context,pasw): print("L3 - Enter the Password {} in Login Screen".format(pasw)) @then("Verify {screen} Screen") def methodFour(context,screen): print("L4 - {} screen".format(screen))