Nested IF, ELSE IF statements inside a while loop not working,

Error: ‘Else If’ is a reserved keyword. It must be an upper case ‘ELSE IF’ and follow an opening ‘IF’ when used as a marker.

Code snippet below:

${rowCount}= Get Element Count (//div[@aria-colindex=‘6’])
WHILE ‘${rowCount}’ != ‘0’
${fillRows}= Get Text (//div[@aria-colindex=‘6’])[${rowCount}]
Sleep 5s
IF ‘${fillRows}’ == ’ ’
Double Click Element (//div[@aria-colindex=‘6’])[${rowCount}]
Wait Until Element Is Visible (//div[contains(@id, “option-1”)]) 60s
Click Element (//div[contains(@id, “option-1”)])
${rowCount}= Evaluate ${rowCount}-1
ELSE IF ‘${fillRows}’ != ’ ’
${rowCount}= Evaluate ${rowCount}-1
END

My question is how would I nest these so the bot won’t error out… OR any suggestions on how to write nested if statements inside of a while loop?

Hi @vdavis345,

Maybe you have it and didn’t show everything but it seems you are missing an END?

It should be something like this:

${rowCount}=    Get Element Count    (//div[@aria-colindex=‘6’])
WHILE    ‘${rowCount}’ != ‘0’
    ${fillRows}=    Get Text    (//div[@aria-colindex=‘6’])[${rowCount}]
    Sleep    5s
    IF    ‘${fillRows}’ == ’ ’
        Double Click Element    (//div[@aria-colindex=‘6’])[${rowCount}]
        Wait Until Element Is Visible    (//div[contains(@id, “option-1”)])    60s
        Click Element    (//div[contains(@id, “option-1”)])
        ${rowCount}=    Evaluate ${rowCount}-1
    ELSE IF    ‘${fillRows}’ != ’ ’
        ${rowCount}= Evaluate ${rowCount}-1
    END # End the if statement
END # End the while statement

Dave.