Forum Discussion
Kitt
3 years agoRegular Contributor
You can also use the 'Background' keyword to set a pre-condition before each scenario. Then create a custom step definition to do as you wish. [Gherkin Reference]
Feature: scenarioTEST
# BACKGROUND: can contain one or more Given steps, which are run before each scenario.
Background: A Browser has been launched and the data has been refreshed
Scenario: Test User Login
# GIVEN/WHEN/THEN: precondition/action/validate
Given The Browser is running
And The user wants to log into the "QA" environment
And The user has navigated to the webpage "https://www.yourwebsite/com"
When The user enters "your@email.com" in the edit Email box
And The user enters "********" password
And The user clicks Log In
Then The user should be redirected to "https://www.yourwebsite.com/redirect"
# SCENARIO OUTLINE: keyword can be used to run the same Scenario multiple times, with different combinations of values.
Scenario Outline: Login with various user roles (data-driven test)
Given The <user> has logged into YourWebsite
When The correct <email> and <password> has been used to login
Then I should see the user <role> listed in the navigation bar
Examples:
| user | role | email | password |
| "User1" | "Super Admin" | "user1@email.com" | "********1" |
| "User2" | "Admin" | "user2@email.com" | "********2" |
| "User3" | "User" | "user3@email.com" | "********3" |
and your step definition inside your script unit would define what happens before each scenario:
When("A Browser has been launched and the data has been refreshed", function (){
CommonMAIN.refreshTestData();
});
Related Content
- 4 years ago
Recent Discussions
- 13 hours ago
- 4 days ago