automationkaratecucumber-junit

How to hit the url again in karate if I am getting 504 gateway timeout error sometimes


I am trying to write one karate script. The URL is working completely fine in postman and even in karate. But the problem is in one of the scenarios a particular test case is failing because of 504 gateway timeout error, the server didn't respond in time. But again in the next run the same scenario and test case is passing but some another scenario or test case is failing because of same 504 error. So is there anyway I can rehit the URL until I don't receive the 504 error.

I tried increasing my readTimeOut and connectionTimeout but nothing is working. I also used karate.configure('retry',{ count:4, interval:5000}); in my karateconfig.js file but nothing is working. Can someone help me to overcome this issue and rerun all test cases until they pass?


Solution

  • You can use retry until feature.

    Refer- https://github.com/karatelabs/karate#retry-until

    There are examples provided to use the response code.

    And retry until responseStatus == 200