1

My feature is something like this:

Scenario:  Searching Value
* def Search = generateRandomNumberFive(111,999)
* call read('classpath:services/common.feature')
Given url domain + '/localhost/mysearch?query=' + Search
And headers scenarioHeaders
And retry until myRecord != $response.suggestions[0].ID == 8
When method get
Then status 200
* def myRecord = $response.suggestions[?(@.ID==8)]

I would like iSearch value to be regenerated on succeeding retries. Thanks for your help, everyone and to @peter-thomas in advance!

Drachir
  • 59
  • 7

1 Answers1

1

And retry until myRecord != $response.suggestions[0].ID == 8

That's definitely incorrect. A retry expression has to be pure JS. This is explained in detail here: https://stackoverflow.com/a/55823180/143475

So you should get rid of the $ - that is JsonPath (not JS).

And retry until myRecord != response.suggestions[0].ID == 8

If you need the Search to be re-generated, I think your only option is to loop manually, see polling.feature. The way that the Karate retry until works is that it will re-play the request as-is and you can't modify it.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I would like to re-generate Search value and re-run the request with new Search value. Is this possible? Thanks in advance! – Drachir Jan 07 '20 at 08:29
  • @Drachir I already said that it is not possible unless you write a loop manually. please read my answer carefully. If you feel so strongly about this, kindly contribute code, this is open source. – Peter Thomas Jan 07 '20 at 09:15