BDD cucumber Secondary keywords in feature file
Secondary keywords in feature file
Below are some lists of secondary keywords which can be use in feature file while writing test case.
1. # (hash sign): -
hash(#) is used to comment the line in feature file. So for commenting any line in feature file, we can put # before the start of the line.
2. @ (at the rate of): -
@ is used for mentioning the tag name in feature file. Tag name is use for running a specific scenario in feature file. This can be at feature level, scenario level, Examples level and etc. One scenario can have multiple tag names. Example is given below.
#Here hash is used to comment this line. @e2e @regression Feature: This is my first feature file @smoke Scenario Outline: This is scenario outline with example keyword When Enter customer name <name> @test Examples: |name| |kabir| |khan|
3. | (pipe line sign):-
In “Examples” keyword, pipe (|) line is used for entering multiple fields test data in the steps. This also used for passing lists of items in specific test step. Example is given below.
Passing list parameters in cucumber from feature file to step definition.
Step in Feature file
And the lists are given below:
|Laptop|
|Kitchen|
|home_Appliances|
Step definition
@And("the list are given below:(.*)") public void ListOfItem(List<String> list) { System.out.println(list); }
Passing parameters in cucumber feature file in step definition.
Step in Feature file
When Enter customer name <name> @example Examples: |name| |kabir| |khan|
Step definition
@When("^Enter customer name (.*)$") public void enter_CustomName(String name) { System.out.println("Scenario outline :- "+name); }
4. “”” (Three inverted comma):-
This symbol is used for putting large or multiple line text in the steps. Example is given below.
Step in Feature file
Then user able to see the large text:
"""
Below are the list of items which can be selected
user can select any value
"""
Step definition
@Then("user able to see the large text:(.*)") public void largeText(String text) { System.out.println(text); }
5. “” (Double inverted comma):-
Double inverted comma is used to passing test data in the step. Example is given below.
Step in Feature file
Given user logged with "userID"
6. <> (greater than less than sign) :-
This is used for passing the reference of test data in test step from feature file. Example is given below.
Step in Feature file
And user select also select item <item>
Step definition
@And("^user select also select item ([^\\\"]*)$") public void navigate_to_home_page3(String Items) { System.out.println(Items); }
7. “<>” (greater than less than sign with inverted comma):-
This also used for passing the reference of test data in the test step. Example is given below.
Step in Feature file
When user select item "<number>"
Step definition
@When("^user select item \\\"(.*)\\\"$") public void navigate_to_home_page2(String number) { System.out.println(number); }
steroid satın al
ReplyDeleteheets
CHDZF5