How to pass the Parameter?
Passing parameter by using “” (double quotes) OR <> sign
From feature file, we can pass a single parameter by using “” in the step.Example is given below.Step in Feature file
Given user logged with "userID"
Step in Feature file
Feature: This is my first feature Scenario Outline: This shopping scenario When user select item <number> Examples: |number| |one| |two|
Step definition (This step definition can used for above both the feature file examples)
@When("^user select item (.*)$")
public void navigate_to_home_page2(String number) {
System.out.println(number);
}
Passing group of conditions in Step definition.
Some time we have to pass a group of condition in step definition. Example is given below.Step in Feature file
Then apple is sweet
Step definition
@Then (“^(?:apple|mango|cherry) is sweet$”)
public void apple_is_sweet() {
System.out.println("fruits");
}
Passing the list of parameter from feature file.
pipe (|) line can also be used for passing lists of items in specific test step. Example is given below.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);
}
You Can Also View Related Topics :-
.
No comments:
Post a Comment