teak
10 years agoContributor
Conditional goto
I dont have any experience with the Conditional goto step. When I try to "run the current condition against the previous responce" I get: "Condition not true for current response in [Product_Details...
- 10 years ago
Hi again Teak,
Its not a direct answer to the issue with the conditional goto TestStep (not sure how well they work with JSON), but since you are doing well with your Groovy, I thought I'd suggest a Groovy alternative that I personally find more flexible:
import static com.jayway.jsonpath.JsonPath.parse def response = context.expand( '${REST Request#Response}' ) def id = parse(response).read('$.id') log.info id if (id!=null) testRunner.gotoStepByName("TestStepName")
So, instead of teh Conditional Goto TestStep, if you instead create a Groovy TestStep after your Request TestStep, then the above code shows how you could:
1) Get the response JSON from (in this case) a REST Request TestStep called REST Request.
2) Parse the JSON response using JSONPath
3) Test the value of id from the JSON document, and use the programatic equivalent of conditional goto.
Hope this helps,
Cheers,
Rupert