Gherkin is the language Cucumber uses to write the tests. Gherkin uses simple English words Given, When, Then, And and etc. as keywords to write the tests.
Step 1: Creating a Feature file
Create a package like 'features', right click on it --> New --> Select File. Enter the file name with '.feature' extension. And then click 'OK' button.
You should see the file being created, and Cucumber green color icon before its name.
Step 2: Writing a Feature
Start with 'Feature' keyword and write the feature we are going to validate as below. We can write comments below it
Step 3: Writing a Scenario
When you press enter after writing Feature, the cursor starts after two spaces indentation. For pretty formatting Cucumber follows indentation.
Start a line with keyword 'Scenario' and write the scenario to be validated. You can write any number of scenarios in a feature.
Step 4: Writing the Steps
Use the Gherkin keywords like Given, When, And, Then to write the steps as below. Here we are taking two simple scenarios of Gmail login page
And you should see steps being highlighted in some kind of yellow color. The reason is this steps are haven't got their step definitions.
In the next post we will write the step definitions for the steps written. We will go step by step and I do not want to make it clumsy.
Thanks for reading!! #seleniumbabu #HappyLearning
Step 1: Creating a Feature file
Create a package like 'features', right click on it --> New --> Select File. Enter the file name with '.feature' extension. And then click 'OK' button.
You should see the file being created, and Cucumber green color icon before its name.
Step 2: Writing a Feature
Start with 'Feature' keyword and write the feature we are going to validate as below. We can write comments below it
Step 3: Writing a Scenario
When you press enter after writing Feature, the cursor starts after two spaces indentation. For pretty formatting Cucumber follows indentation.
Start a line with keyword 'Scenario' and write the scenario to be validated. You can write any number of scenarios in a feature.
Step 4: Writing the Steps
Use the Gherkin keywords like Given, When, And, Then to write the steps as below. Here we are taking two simple scenarios of Gmail login page
And you should see steps being highlighted in some kind of yellow color. The reason is this steps are haven't got their step definitions.
In the next post we will write the step definitions for the steps written. We will go step by step and I do not want to make it clumsy.
Thanks for reading!! #seleniumbabu #HappyLearning
Wonderful blog on Selenium automation testing and it plays a major role in each and every organization. Thanks for providing such a wonderful article.
ReplyDeleteSelenium Training in Chennai
Selenium Training