With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, CSV, SQL, MOCA, and Datastore sources provide more dynamic permutations and less maintenance.
This article details what the Example Row source is, as well as why and how to use it.
Example Row is the keyword used in Scenario Outlines to set a single row of test parameters to be used in execution. The format of Example Row is the keyword Example Row: followed by space separated key="value" pairs.
Example:
Scenario Outline: Validate Tryon Home Page Text Elements
Example Row: browser = "Chrome" site = "https://cyclelabs.io/playground/#!/main/orders" element = "className:header" value = "(888) 256-2177"
Example Row can be used in the Step building process to create the test. Instead of loading a huge dynamic set of test parameters every iteration while constructing your Feature you can use Example Row to provide a once through for process or Step validation.
Example Row data can also be used to help build and verify pieces of the test parameter data. Using the example provided above we are testing web elements on a home page. We can use Example Row to validate whether we have identified the right elements and the right format individually before adding them into the entire set of test parameters.
Example Row is used with the keyword Scenario Outline:. As in the previous example illustrates, it is declared on the line immediately following Scenario Outline.
To set key-value pairs, provide a parameter name followed by the equal sign followed by the parameter value. Additional key-value pairs are space separated.
The Example Row line is followed by the Scenario execution steps.
When the Scenario Outline is executed the key-value pairs you assigned will be converted into chevron variables to use in the Steps with the value you provided.
For example if you assigned the key-value pair browser = "Chrome" then Steps use the chevron and variable replacement to use the information provided.
Given I open <browser> web browser
When the Step executes <browser> will be replaced with Chrome.
In this example, the Steps are designed to validate whether the text in the element on the web page matches the expected value. The goal is to execute this for all the identified elements but we are using Example Row to start validating our process and build the list of parameter data.
Scenario Outline: Validate Grocer Home Page Text Elements
Example Row: browser = "Chrome" site = "https://cyclelabs.io/playground/#!/main/orders" element = "className:header" value = "(888) 256-2177"
Given I open <browser> web browser
Then I navigate to <site> in web browser
Then I maximize web browser
Then I see <value> matches all text in element <element> in web browser within 5 seconds
Then I close web browser