Create a Gherkin Scenario

Gherkin syntax is built to be a human-readable way to describe your flow events for easier understanding. A Gherkin Scenario can include any of the following steps:

Given

When

Then

And

But

 

In order to create a Gherkin scenario, follow these steps:

  1. In a suite, click + Add to add a new test and select Gherkin Scenario

    image-20240201-160711.png
  2. Specify a Name, Keywords and Comments for your scenario.

    image-20240201-160732.png
  3. Click Steps to move to step view. The scenario will automatically show 3 steps as shown below:

  4. To begin your Gherkin scenario, click on one of the steps to display the right panel. For example Given <NOT_SELECTED> [empty]

  5. If you click on the dropdown list in the right panel, you can always change the step from Given to any of the other options displayed.

  6. Click the Select or Type… field and begin entering your Given scenario. If you would like to create a command template which will include parametrized data, you can use <> to indicate the start and end of the parameter name. Let’s enter The user navigates to site <website>.

  7. By pressing Tab on your keyboard, the Gherkin Step will be displayed. If you click the View Gherkin step (Eye icon), a new Gherkin Step window will appear with 2 blank steps so you can add as many steps as you like.

  8. As you can see, a parameter has also been automatically created for you to use with TEXT. If you click the Parameters link, you can click on the dropdown list to change the type from TEXT or BOOLEAN or CHOICE depending on your scenario. Refer to Command Templates (BETA) to learn more about command templates parameters.

  9. Click Steps tab to move into steps view. Let’s add a step to navigate to a website which we can parameterize. First thing is to click on the blank step to show the right panel, then select Goto URL command

  10. After selecting Goto_URL command, we can navigate to any website. By entering @website, we are calling the variable from the parameter previously created. Let’s save the scenario by clicking Not Saved.

     

  11. When closing the New Gherkin Step window and returning to the New Gherkin Scenario window, we will see that the new step has been added with the newly created step. Next to the website parameter, we can start to add a website to navigate to. You can add static values, but we recommend using datasets to prevent hard-coding, this will also allow you to add multiple values in different datasets that you can select in your test. Click on the input box next to website and click Inject Template icon.

  12. Create a new Data Template and Dataset, or select an existing one. Refer to Create a Data Template and Create a New Dataset for further help on Data Templates or Datasets.

  13. Once the Data Template and Field are selected, click Inject and you will see a parameterized value. For example ${subject7_reference_environment.url}

  14. Click on the next step to display the right panel and begin adding your next steps. For example, let’s create a step with The user will log in with <username> and <password

  15. Click the View Gherkin Step (Eye icon) icon again to begin adding your logging in steps. When you add the steps which will fill in the data, call the variable from the parameter created in step 15.

  16. Save your Gherkin step and return to the Gherkin Scenario. Now you can select your username and password either by filling them or injecting them as you did in steps 11-12.

  17. Expand your next step to add a new Gherkin Step which will execute after logging in. For example: Verify that the user with name <full_name> has logged in

  18. Click the View Gherkin Step (Eye icon) icon again to begin adding your verification steps (if any) and save the Gherkin step. The below example shows verification using the parameter created in step 18.

  19. If you have any additional steps, you can simple click the blank step with “Select Command” placeholder to display the right panel. For example, let’s add And to log out of the application.

  20. Let’s create steps to log out of the application. By clicking View Gherkin step (Eye icon) we can add that step.

  21. Click Save on your Gherkin step

  22. Return to your Gherkin Scenario and save it.

  23. Now as you can see, the Gherkin Scenario is complete. We can save it and execute it locally or in cloud

  24. In order to switch between datasets, you can click the Select Dataset icon highlighted below:

     

     

Related pages