Karate - How to use retry until when there are 2 different requests in the same scenario

Viewed 179

If I send one request in a scenario and use retry until as shown in the syntax below then the retry until works fine:

  Scenario Outline: x
    Given url 'x'
    Then retry until status 200
    When method get
    
    Examples:
      | productId | postcode | 
      | 'xxxx' | 'yyyy' | 

However, if I then send ANY other request afterwards (to make things simple I will just send exactly the same request)..

  Scenario Outline: x
    Given url 'x'
    Then retry until status 200
    When method get

    //Send ANY other request here:
    When method get
    
    Examples:
      | productId | postcode | 
      | 'xxxx' | 'yyyy' | 

Then I see the following error message:

11:59:09.820 [main] WARN  com.intuit.karate - retry condition evaluation failed: js failed:
>>>>
01: status 200
<<<<
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:1:7 Expected ; but found 200
status 200
       ^

How do I use retry until when there is more than one request sent in the scenario?

2 Answers

(1) retry until must come BEFORE each method keyword (2) The correct syntax = retry until responseStatus == 200

Scenario Outline: x
    Given url 'x'
    Then retry until responseStatus == 200
    When method get

    //Send ANY other request here:
    Then retry until responseStatus == 200
    When method get
    
    Examples:
      | productId | postcode | 
      | 'xxxx' | 'yyyy' | 
Related