How can we use "Set Variable if" with a keyword where Keyword is returning a variable RobotFramework

robotframework

Solution

Actually, the easiest way to do it is by using `Run Keyword If` instead of `Set Variable If` like below:

Foo
    ${ret}=    Run Keyword If    ${i} == 10    Keyword Which Return Something
    Should Be Equal    ${ret}    something

Keyword Which Return Something
    ${var}=    Set Variable    something
    [Return]    ${var}

Problem

How can we use `Set Variable if` with a keyword, where Keyword is returning a variable that needs to be Set in `RobotFramework`. Eg: `${Var} = set variable if ${i}==10 Keyword`.

Original source