Search code examples
web-api-testingkarate

How can is store the value of an element in a API response from one scenario and use the variable in the other scenarios in the same feature file?


Consider I am having three scenarios in my feature file. I want an authorization token that I get from an API response in the first scenario to be used in the other scenarios.

I declare the variable in "Background:" section. How to use the variable across scenarios?


Solution

  • Any variable declared in the Background: will be available for use in all Scenario:s in the same feature.

    Refer to this answer for more: https://stackoverflow.com/a/46080568/143475