What are the methods available in the Cucumber Scenario?
Cucumber Scenario:
- Scenario is a class provided in the io.cucumber.java package.
- In Cucumber we will write our test cases using Scenario keyword.
- While executing scenarios we need to know the information of executing scenarios like Status of scenario, scenario path, etc.,.
Below are Scenario methods which are frequently used in the framework:
- getName()
- getId()
- getUri()
- getLine()
- isFailed()
- getSourceTagNames()
- getName(): It will return the name of the scenario.
- getId(): It will return the id of scenario. (Syntax: <feature file uri>:<line number>)
- getUri(): It will return the Uri of the Scenario.
- getLine(): It will return the line number in the feature file of the scenario.
- isFailed(): It will return boolean value.Return True if scenario is failed.
- getSourceTagName(): It will return tags of the current execution of scenario.
Demo program on Cucumber Scenario Methods:
Let's say I have a scenario like below:
Feature: Demo on cucumber framework
Description: The purpose of this feature is to explain Scenario class in cucumber
@smoke @regression Scenario: This is First Scenario Given I navigated to keeplearners blogspot And I search for Java And I search selenium And I search for cucumber Then I close the browser
cucumber scenario methods |
Scenario methods in Cucumber |
Cucumber getLine():
In case of Scenario Outline, it will return line number of Examples row.
Let's say I have a Scenario outline like below:
Cucumber Scenario outline getLine() |
Execute above scenario:
Cucumber Scenario getLine() method |
Please comment below to feedback or ask questions.
No comments:
Post a Comment
Please comment below to feedback or ask questions.