2021年5月4日星期二

Robot Framework - why am I getting "'If' is a reserved keyword" error?

This is my first time attempting to use an IF condition in the Robot Framework and I am finding it to be surprisingly hard. My test fails with the message: 'If' is a reserved keyword. Well, yes -- and I want to use that keyword!

Here's the snippet of relevant code.

    # Column lookup using ${heading}      @{heading_list}  Create List      @{header_element_list}  Get WebElements  ${table_headers_locator}      FOR  ${element}  IN  @{header_element_list}          Append To List  ${heading_list}  ${element.text}      END      ${col}  Get Index From List  ${heading_list}  ${heading}      IF  ${col} < 0          Fail  Heading '${heading}' not found in table.      END  

I'm working in PyCharm, with a Robot Framework code syntax highlighting plugin. The plugin also seems to think that there's something amiss with the IF condition; note that its keywords are colored light blue, whereas the keywords in the FOR loop immediately above it are colored orange.

enter image description here

I believe that my IF statement conforms to the simplest example of an IF statement, as shown in the Robot Framework documentation here: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#advanced-features. Please help me to understand why this is not the case. Thanks!

https://stackoverflow.com/questions/67393953/robot-framework-why-am-i-getting-if-is-a-reserved-keyword-error May 05, 2021 at 09:06AM

没有评论:

发表评论