Increase the value of the variable in iteration for the frame of the robot cycle

I need to increase the test variable ${success_num}in For Loop: But it is always 0, even after I add 1 to it. It seems to have been reset after each iteration. How to increase its value?

*** Test Cases ***
    ...
    ...
    Set Test Variable    ${success_num}    ${0}
    App For Port    ${actual_app}
    ...
    ...

*** Keywords ***
App For Port    [Arguments]    ${app}
    : FOR    ${port_num}    IN    1    2
    \    ${PorF}    ${message}    Run Keyword And Ignore Error    applicationcontrol.Launch application    ${app}    ${port_num}
    \    Continue For Loop If    '${PorF}'=='FALSE'
    \    ${status}    Run Keyword And Return Status    Check launching status    ${app}    ${port_num}
    \    Continue For Loop If    '${status}'=='False'
    \    Run Keyword If    '${status}'=='True'   Add Success
    \    Exit For Loop

Add Success
    ${success_num}    Set Variable    ${success_num+1}
+4
source share
2 answers

Change the keyword Add Successto:

Add Success
    ${temp}    Evaluate    ${success_num} + 1
    Set Test Variable    ${success_num}    ${temp}
+1
source

You do not need to call a keyword to increase success_num:

App For Port    [Arguments]    ${app}
    : FOR    ${port_num}    IN    1    2
    \    ${PorF}    ${message}    Run Keyword And Ignore Error    applicationcontrol.Launch application    ${app}    ${port_num}
    \    Continue For Loop If    '${PorF}'=='FALSE'
    \    ${status}    Run Keyword And Return Status    Check launching status    ${app}    ${port_num}
    \    Continue For Loop If    '${status}'=='False'
    \    ${success_num} =  Run Keyword If    ${status}    Set Variable  ${success_num}+1    ELSE    Set Variable    ${success_num}
    \    ${temp} =  Run Keyword If    ${status}    Evaluate  ${success_num}+1    ELSE    Evaluate    ${success_num}
    \    Set Test Variable  ${success_num}  ${temp}
    \    Exit For Loop
+2
source

Source: https://habr.com/ru/post/1663010/


All Articles