Feature File Design

Let see now, What type of data consists inside the feature file.

It has terms like Feature , Scenario , Given , Then,When ,And,But.

Feature : We need to define the feature name first. In a single feature file we can have only one feature name.

Scenario : After defining the feature name now we should define the scenario name.In one feature file we can define any number of scenarios.

Now under scenario name we should define steps as Given,When,Then ,And, But

  • Given : This tag is used when we starts interacting with the Application(Like- Precondition)
  • When : This tag is used when we perform some actions on application (Interacting with Application such as Entering data in login form)
  • Then : This tag can be used in verification steps
  • And , But : This tags will be used for preceding tags for (Given,When ,Then) to descript more additional steps for (Given, When,Then)

Feature File

Example : We have created a feature file as login_screen.feature and define two scenarios in it.

login_screen.feature

# This is a Feature file

Feature: Fill the Contact Form

    Scenario: User Login credentials

        Given Launch the App and Click on Login Button
        When Enter UserID
        When Enter password
        When click on Login Button
        And Home page opens
        Then Verify Home Screen
        Then Take screenshot


    Scenario: Enter the data in Contact Form

        Given Launch the App and Click on ContactForm
        When Enter Name
        When Enter Email
        When Enter Mobile Number
        And we need to click on submit button
        Then Click on submit
        Then Take Screenshot of contact Form