-1

I am defining a variable in scenario 1 to obtain a value from response and trying to insert this as param in another scenario. But scope of variable is till scenario. How can I use my variable from scenario1 to use in scenario 2?

1 Answers1

1

you can save this data into a variable and then read it in other .feature file.

Example:

Feature1

    Given path '/api/mobile'
    And header Authorization = Token
    When method GET
    Then status 200
    And match response ==
    """
    {
      "passes": "#number"
    }
    """
    * def passesResponse = response.passes

Feature2

   Scenario: Update Mobile Passes For The Account
    * def mobilePasses = call read('classpath:helpers/scenarios/Feature1.feature')
    * def passes = mobilePasses.passesResponse
    Given path '/v2/update/passes'
    And request {"addPass": passes}
    Given header Authorization = Token
    When method PUT
    Then status 200

More info you could find here: link