重试期间是否有办法在KarateDSL中传递新请求?谢谢, [英] Is there a way to pass a new request in KarateDSL during retry? Thank you,
问题描述
我的功能是这样的:
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)]
我希望在以后的重试中重新生成iSearch值.谢谢大家的帮助,并提前感谢@ peter-thomas!
I would like iSearch value to be regenerated on succeeding retries. Thanks for your help, everyone and to @peter-thomas in advance!
推荐答案
然后重试,直到myRecord!= $ response.suggestions [0] .ID == 8
And retry until myRecord != $response.suggestions[0].ID == 8
那肯定是不正确的.重试表达式必须是纯JS.此处详细说明: https://stackoverflow.com/a/55823180/143475
That's definitely incorrect. A retry expression has to be pure JS. This is explained in detail here: https://stackoverflow.com/a/55823180/143475
因此,您应该摆脱$
-JsonPath(而不是JS).
So you should get rid of the $
- that is JsonPath (not JS).
And retry until myRecord != response.suggestions[0].ID == 8
如果需要重新生成Search
,我认为唯一的选择是手动循环,请参见
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.
这篇关于重试期间是否有办法在KarateDSL中传递新请求?谢谢,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!