Reputation: 1064
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.
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!
Upvotes: 5
Views: 8257
Reputation: 1064
Bryan Oakley wrote: "It looks like the plugin hasn't been updated to support robot 4.x", and this caused me to dig a little deeper. My employer's automation team has specified Robot 3.1.2! This is not something that I can change.
The documentation online states that the IF expression was added to the language in Robot 4.0. And it is therefore correct that my syntax highlighting for the IF statement does not agree with what I expect -- because Robot 3.x does not process conditional statements in that way.
Personally, I find it bizarre that something as basic as an IF expression is actually a cutting-edge language feature. But, knowing the limitations imposed by Robot 3.x, I will devise a workaround.
Upvotes: 3