Cucumber Multiple Scenario Outline Variables to Construct String

Profile picture for user devraj

In previous Scenario Outline example we have discussed, how the Scenario Outline keyword or variable can be used to run the same Scenario multiple times, with different combinations of values.

  @temp
  Scenario Outline: Verify Login Functionality
    And I fill in "email" with "<email>"
    And I fill in "passwd" with "<password>"
    And I press "SubmitLogin"
    Then I should see "<heading>" heading

    Examples:
      | email                     | password  | heading        |
      | goswami.tarun77@gmail.com | Test@1234 | MY ACCOUNT     |
      | wrongusername             | test      | AUTHENTICATION |

Now consider this case, I was testing one of the investment banking application. Where I have to submit Trade & ETF form after selecting several combination of values and after clicking on review order button, review modal appear where I have to assert few values based on combination of variables value selected. Here we are constructing a string and then asserting based on variables value.

investment banking application

Review Modal

review Modal

You can construct such string using multiple scenario outline variables. For Example:

@Demo 
Feature: For Demo only 

Scenario Outline: Verify information on review Modal 
	When I follow "Stocks & ETFs" link 
	And I fill in Symbol with "<symbol>" 
	And I select "<account>" from account dropdown 
	And I select "<action>" from Action dropdown 
	And I fill in quantity with "<quantity>" 
	And I select "<order type>" for order type 
	And I fill in price with "<price>" 
	And I select "<time>" from Time in force 
	Then I should see "<action> <quantity> <symbol> @ <order type> <price> - <time>" 
	Examples: 
		|symbol|account|action|quantity|order type|price|time|
		|ABCD|X|Buy|1|Limit|10|Day 9:30AM - 4:30PM ET|
		|XYZE|Y|Sell|2|Trailing Stop $|20|Day 6:30PM - 2:30AM ET|

So, this is possible use as many variables as you want inside double quotes, this all will be replaced with corresponding value in example section.