Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Run Keyword If" and setting a variable

The following code doesn't work. I want to set a variable if a condition is true.

    Run Keyword If    ${MAC} == 110299160221421    ${device_serial}=    set variable    ${device_serial_1}

I get the error:

No keyword with name '=' found

This is working but doesn't change a variable.

    Run Keyword If    ${MAC} == 110299160221421    Log to console    111
like image 931
kame Avatar asked Sep 25 '22 06:09

kame


1 Answers

Run keyword if returns the result of the keyword that you're running. So, like with any other keyword, you put a variable in the first column if you want to save the value:

${device_serial}=  run keyword if  ${MAC} == 110299160221421  
...    set variable    ${device_serial_1}

I this specific case you might want to use Set Variable If instead of Run Keyword If

${device_serial}=  set variable if  ${MAC} == 110299160221421
...    ${device_serial_1}
like image 122
Bryan Oakley Avatar answered Oct 18 '22 16:10

Bryan Oakley