0

I have a robot test case as shown below:

*** Test Cases ***
Login Test
    ${jsonfile}    OperatingSystem.Get File   ${EXECDIR}/test/testData/LoginTestData.json
    ${source data}=    Evaluate     json.loads("""${jsonfile}""")    json
    ${all data members}=    Set Variable     ${source data['testcase']}
    FOR    ${member}    IN    @{all data members}
        Keyword 1   ${member} 
        Keyword 2   ${member} 
        .........
        Keyword n   ${member} 
   END

For any test data, if any keyword e.g 'Keyword 2' fails, I want to stop executing other keywords(e.g. Keyword 3 to Keyword n). But the loop should continue for other test data. How could I make this?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
ab.sharma
  • 180
  • 3
  • 12

2 Answers2

1

Run each keyword inside Run Keyword And Return Status and if it's False call Continue For Loop If to start a new iteration:

        ${passed}=    Run Keyword And Return Status  Keyword 1   ${member}
        Continue For Loop If    not ${passed} 
        ${passed}=    Run Keyword And Return Status  Keyword 2   ${member}
        Continue For Loop If    not ${passed}
Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
0

You can use the Run Keyword ... family. For example Run Keyword And Continue On Failure, or Run Keyword And Ignore Error.I often use Run Keyword And Return Status for these cases.

Helio
  • 3,322
  • 1
  • 14
  • 23