ReplaceRunKeywordIf#
Replace Run Keyword If
keyword calls with IF expressions.
Transformer configuration
ReplaceRunKeywordIf is included in the default transformers, but it can be also run separately with:
robotidy --transform ReplaceRunKeywordIf src
You can also disable ReplaceRunKeywordIf:
robotidy --configure ReplaceRunKeywordIf:enabled=False src
*** Keywords ***
Keyword
Run Keyword If ${condition}
... Keyword ${arg}
... ELSE IF ${condition2} Keyword2
... ELSE Keyword3
*** Keywords ***
Keyword
IF ${condition}
Keyword ${arg}
ELSE IF ${condition2}
Keyword2
ELSE
Keyword3
END
Any return value will be applied to every ELSE/ELSE IF branch.
*** Keywords ***
Keyword
${var} Run Keyword If ${condition} Keyword ELSE Keyword2
*** Keywords ***
Keyword
IF ${condition}
${var} Keyword
ELSE
${var} Keyword2
END
Run Keywords inside Run Keyword If will be split into separate keywords.
*** Keywords ***
Keyword
Run Keyword If ${condition} Run Keywords Keyword ${arg} AND Keyword2
*** Keywords ***
Keyword
IF ${condition}
Keyword ${arg}
Keyword2
END
Run Keyword If that assigns values but does not provide default branch will receive ELSE branch with Set Variable:
*** Keywords ***
Keyword
${var} Run Keyword If ${condition} Keyword
*** Keywords ***
Keyword
IF ${condition}
${var} Keyword
ELSE
${var} Set Variable ${None}
END