Skip to main content

Cucumber Multiple Scenario Outline Variables to Construct String

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.

Submitted by tgoswami on November 11, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.