The condition passed to Run keyword if
needs to be a valid python expression after substituting.
The easiest solution is to do one or both of the following:
- use triple quotes to quote the string
- use robot's ability to directly use the variable as
$Key1
rather than ${Key1}
Also, it's not necessary to escape the quotes when calling Set Variable
. They are harmless but make the code harder to read.
For example, the following example uses both techniques and should pass:
*** Variables ***
${KEY_FLAG} ' and "
*** Test Cases ***
Example
${Key1}= set variable It's in "Detailing": The Perfect Gift ${KEY_FLAG}
run keyword if $Key1=='''It's in "Detailing": The Perfect Gift ' and "'''
... pass execution the condition is true
fail the condition is false