1

I am trying to use Run Keyword If with or but for some reason it does not work and I could not understand why. It shows me an error No keyword with name 'or' found. I assume there is some syntax error. I also tried with OR but it did not work.

Keyword 1
Check Walkthrough Guide Opened
Go to    ${WALKTHROUGH_URL}
Open Walkthrough Guide If It's Closed
Wait Until Element Is Visible    ${WELCOME_POPUP}    ${WFE_TIMEOUT}
Page Should Contain Element    ${POPUP_TITLE}

Keyword 2
${ELEMS}=    Execute JavaScript    return localStorage.getItem('peopleAnalyticsTourDismiss')
Run Keyword If    ('${ELEMS}' == 'true')  or  (${ELEMS}' == 'None')   Run Keywords
...    Execute Javascript    localStorage.setItem('peopleAnalyticsTourDismiss', 'false')
...    AND    Reload Page
oksa23
  • 45
  • 7

2 Answers2

2

You need to convert the two spaces on either side of "or" to a single space. Robot sees the two or more spaces and thinks "or" is the keyword to run.

Run Keyword If    ('${ELEMS}' == 'true')  or  (${ELEMS}' == 'None')   Run Keywords
#                                       ^^  ^^
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
2

Robot Framework is understanding your OR as the second argument of the keyword Run Keyword If. Switch the double spaces for a single one, like the example below:

Run Keyword If    ('${ELEMS}' == 'true') or (${ELEMS}' == 'None')   Run Keywords

This way, robot will understand ('${ELEMS}' == 'true') or (${ELEMS}' == 'None') as just one argument of Run Keyword If, with is the condition one.

If you still have doubts, I've found this issue with a similar problem, and a good solution as an example.

Other thing that can be giving you some trouble, is that you missed a ' in the beggining of the second comparison: or (${ELEMS}' == 'None'). Try changing it for one of the options below:
or ('${ELEMS}' == 'None')
or ("${ELEMS}" == "None")
or ("""${ELEMS}""" == """None""")

Please refer to the Builtin library for doubts about triple quotes.