Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 378
Anks Avatar asked Mar 24 '23 04:03

Anks


1 Answers

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}
like image 177
Matthieu.P Avatar answered Apr 08 '23 04:04

Matthieu.P