javaseleniumcucumber

How to use nested Scenario Outline in Cucumber java


2suppose i have a Scenario Outline like

@Scenario1
Scenario Outline:Scenario one
    Given fill up login fields "<email>" and "<password>"
    And click the login button
 Examples:
      | email            | password |
      | someEmailAddress | SomePassword | 
      | someEmailAddress2| SomePassword2 | 

and another Scenario like

@Scenario2
Scenario Outline:Scenario two
    Given fill up  fields "<value1>" and "<value2>"
 Examples:
      | value1  | value2  |
      | value11 | value21 | 
      | value12 | value22 | 

How could i run scenario like login with 'someEmailAddress' and fill up with all scenario2 value and then login with 'someEmailAddress2' and do the same.


Solution

  • There is no support for nested scenario outline in Cucumber, but you can use the following way to overcome it.

    Scenario Outline: Scenario one and two
      Given fill up login fields "<email>" and "<password>"
      And click the login button
      And fill up  fields "<value1>" and "<value2>"
    
      Examples:
        | email             | password      | value1  | value2  |
        | someEmailAddress  | SomePassword  | value11 | value21 |
        | someEmailAddress  | SomePassword  | value12 | value22 |
        | someEmailAddress2 | SomePassword2 | value11 | value21 |
        | someEmailAddress2 | SomePassword2 | value12 | value22 |