Reputation: 11
I am preparing a script to automate a test in a website through the selenium robot framework.
There is one XPath that returned ${EMPTY}
and I am trying to assign 0 but it is displaying following error.
Evaluating expression ' == ''' failed: syntaxerror: no viable alternative at input '==' (<string>, line1)
Here is what I wrote:
column1 | column2 | column3 | column4
-------------------------------------------------------------------------
${var1}= | Set Variable if | ${var1}=='${EMPTY}' | ${var1}==0
Will you please help me with the solution?
Thank You Yogi
Upvotes: 1
Views: 6115
Reputation: 2409
You technically do not need single quotes around the built-in variable ${EMPTY}
. If you do choose to use them however, both sides of your comparison statement should be consistent.
${var1} is ${EMPTY}
or
'${var1}'=='${EMPTY}'
Thus, your keyword statement should be as follows:
${var1}= Set Variable If ${var1} is ${EMPTY} 0
Upvotes: 1
Reputation: 2126
I could be wrong as I don't have much experience using this but I think your issue is in the conditional statement. An attempt to revise:
column1 | column2 | column3 | column4 | column5
---------------------------------------------------------------------------------
${var1}= | Set Variable if | '${var1}'=='${EMPTY}' | 0 | ${var1}
To add a bit of explanation to this, it should mean that if var1 is indeed empty, it will set the value of var1 to 0. If it isn't empty, it will retain whatever value var1 is from the XPath.
I'd suggest reading further around it to make sure you've grasped it: http://robotframework.org/robotframework/latest/libraries/BuiltIn.html
Upvotes: 0