Selenium BDD cucumber Keywords in Feature file
Keywords in Feature file
Feature file is use to write the test step in Gherkin language. Below are some important keywords in feature file which are used to write test case.
• Background • Feature • Scenario/Example • Scenario outline • Examples
Background: -
Background keywords in cucumber are used, when we have some common step in each scenario, which need to be executed every time. So instead of writing those common steps in each scenario every time, we can use Background keyword which will execute the background step before each scenario. Background: Given Gmail url launched
Feature: -
Feature keyword is use to describe the feature of the scenario. You can have multiple feature files base on the story or requirement. And you can have multiple scenarios in one feature file. Feature: This is my first feature file
Scenario/Example: -
Scenario as its name indicate, it talk about scenario of that feature. With scenario key work you can execute only one scenario with single parameter Scenario: This is scenario Given user logged with "userID"
Scenario outline: -
scenario outline is used to execute same scenario with different parameter. We can use “Examples” keyword to pass the parameter. We can pass the reference of the parameter Examples: - Examples keyword is use to send the parameter in scenario step. See below example.
Feature: This is my first feature file Background: Given Gmail url launched @login Scenario Outline: This is scenario outline with example keyword When Enter customer name <name> Examples: |name| |kabir| |khan|
Out come :-This is Backgroud Annotation Scenario outline :- kabir This is Backgroud Annotation Scenario outline :- khan
In above example, Background keyword will execute after each scenario. With the help of scenario outline and Examples keyword we can pass the parameter.
0 comments:
Post a Comment