Home > Back-end >  Karate | Can we set payload based on status code condition
Karate | Can we set payload based on status code condition

Time:02-08

We have a post request as below ''' { Parameter : "name" col : 1 } '''

if the status code is 200 then do nothing, if status code is 400, then set value : "test" in the above payload as below and send again.

''' { Parameter : "name" col : 1 value : "test" } '''

CodePudding user response:

Yes.

* if (responseStatus == 200) karate.abort()
* request { second: 'time' }
* method post

If you want more ideas and also why you shouldn't do these kinds of "clever" tests, read this: https://stackoverflow.com/a/50350442/143475

  •  Tags:  
  • Related