Home > Back-end >  Run Keyword If Robotframework
Run Keyword If Robotframework

Time:04-02

Was Iterating inside array and imposing Run Keyword If

    Run Keyword If      "${text}" == "CPNUMBER *******"    Append To List  ${textList}     CP
...  Else If     "${text}" == "FNAME **** ****"   Append To List  ${textList}     FNAME TONY STARK

And the output was

['Create List', 'FNAME **** ****', 'CPNUMBER 1111111', 'Else If', '"${text}" == "FNAME **** ****"', 'Append To List', [...], 'FNAME TONY STARK']

The first two array are correct however the whole else if validation is appended on my list. How can I Filter these names and append to my list.

Im using RBF 3.1

CodePudding user response:

Else If should be in uppercase. In this case, the whole Else If "${text}" == "FNAME **** ****" Append To List ${textList} FNAME TONY STARK is considered as *values, so it is executed as Append To List ${textList} CP Else If "${text}" == "FNAME **** ****" Append To List ${textList} FNAME TONY STARK. Refer to Run Keyword If to see how to do else if.

You should try

    Run Keyword If      "${text}" == "CPNUMBER *******"    Append To        List  ${textList}     CP
    ...  ELSE IF     "${text}" == "FNAME **** ****"   Append To List  ${textList}     FNAME TONY STARK
  • Related