Using Examples Table in Cucumber

Using Examples in Cucumber is a great thing for testing world! Examples is a keyword and you can define a set of variable to repeat your case with the whole set of data in the examples block. 

We can re-write the examples which checks the login page of with Examples feature of Cucumber. Check the following code:

In the amazon_login.feature file we are reading <username>, <password> and <message> variables from the Examples. This means that the scenario which has the steps used these variables will run 2 times, which is the number of row in the examples.

There should some changing in the Capybara, Ruby file. "(.*?)" this means the function takes a string parameter but we are sending table variable so we need to change (.*) for string variable in table and (\d+) for integer variable in table.    

As you can see from the result there are 3 scenarios (3 passed) and 9 steps (9 passed). This means that "Scenario: User goes to login page" run for 1 time and "Scenario Outline: Member logins the page" run 2 times and there are 9 steps passed in total.


Popular posts from this blog

Selenium Error "Element is not currently interactable and may not be manipulated"

Change Default Timeout and Wait Time of Capybara

Page-Object Pattern for Selenium Test Automation with Python

Performance Testing on CI: Locust is running on Jenkins

How to Set Shared Preferences in Espresso Test for Kotlin and Java