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?
Asked
Active
Viewed 359 times
-1
-
you really need to read this now: https://stackoverflow.com/a/46080568/143475 – Peter Thomas Aug 23 '22 at 18:49
1 Answers
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

Ivan Medvediev
- 23
- 5