Kishore
Kishore

Reputation: 139

How to access the response of a scenario from a different scenario?

I have a feature file Product.feature .I have two Scenarios Create Product and Update Product. I have created a product in Scenario :Create Product. In the following scenario(Scenario :Update Product) I want to update the details of the product created in the Scenario : Create Product using the account id which will be in the response of the Scenario :Create Product .

Upvotes: 1

Views: 332

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58153

You have to merge the Scenario-s into one. It looks like you have mis-understood how they have to be used. This is explained clearly in the documentation:

Variables set using def in the Background will be re-set before every Scenario. If you are looking for a way to do something only once per Feature, take a look at callonce. On the other hand, if you are expecting a variable in the Background to be modified by one Scenario so that later ones can see the updated value - that is not how you should think of them, and you should combine your 'flow' into one scenario. Keep in mind that you should be able to comment-out a Scenario or skip some via tags without impacting any others.

Upvotes: 1

Related Questions