-
Book Overview & Buying
-
Table Of Contents
Cucumber Cookbook
By :
Until now we have learned about Scenarios, Steps, Background, and Scenario Outline individually. But when a BA or a PO has to write the Feature file, they have to combine all these keywords to come up with a very efficient and expressive Feature file.
Consider writing a Feature file for a login functionality where the latter meets the following criteria:
All these requirements are specific to the behavior of the application, and none of them are concerned with how you implement these requirements.
Now we are going to use all the keywords we have explored until now, and we are going to create a login.feature file that specifies all the aforementioned requirements:
Feature: login Page
In order to test login page
As a Registered user
I want to specify the login conditions
Scenario: login flow
Given user is on Application landing page
And Sign in button is present on screen
When user clicks on Sign in button
Then user is displayed login screen
When user enters "ShankarGarg" in username field
And user enters "123456" in password field
And user clicks Sign in button
Then user is on home page
And title of home page is "GitHub"
Scenario Outline: Login fail - possible combinations
Given user is on Application landing page
When user clicks on Sign in button
Then user is displayed login screen
When user enters "<UserName>" in username field
And user enters "<Password>" in password field
And user clicks Sign in button
Then user gets login failed error message
Examples:
| UserName | Password |
| wrongusername | 123456 |
| ShankarGarg | wrongpassword |
| wrongusername | wrongpassword |
Scenario: Existing user Verification
Given user is on Application landing page
Then we verify following user exists
| Name | Email | Phone |
| Shankar | [email protected] | 999 |
| Ram | [email protected] | 888 |
| Sham | [email protected] | 666 |
Scenario: New User Registration
Given user is on Application landing page
When user enters "ShankarGarg" in username field
And user enters "[email protected]" in password field
And user enters "123456" in password field
And user clicks on Signup for GitHub button
Then user is successfully registeredHere we have combined all the keywords and concepts discussed until now in this chapter. Let's go through each requirement one by one and analyze how and with which keyword we specified these requirements:
Change the font size
Change margin width
Change background colour