Vitaly
(Vitaly)
1
Hi!
I am trying to add new element to the list if it was not there before.
Run Keyword If ${itemText} not in ${Infostring} Append To List ${Infostring} ${itemText}
But i got error Evaluating expression ’ not in ’ failed: SyntaxError: invalid syntax
How to solve this problem?
FrancisG
(Francis)
2
Yes we do, the syntax error is related to using ${var}
rather than $var
, here is the correct syntax:
Run Keyword If $itemText not in $Infostring Append To List ${Infostring} ${itemText}
More explanations on what syntax is expected by Run Keyword If for its condition: Evaluating expressions
Also ${Infostring}
must be a list for Append To List to be able to work with it.
See whole example working on playground.
5 Likes
Stylewise you could use a the IF
statement which makes the line probably more readable:
IF $itemText not in $Infostring Append To List ${Infostring} ${itemText}
That should work with Robot Framework >=4
If you like, checkout the user guide for more information on IF/ELSE syntax at Robot Framework: Robot Framework User Guide
1 Like