Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

python - Evaluating a expression in quotes failing in robot framework

*** Variables ***

${text1}      Jack's mother said "Hello" to me 
${text2}      Jack's mother said "Hello" to me

*** Test Cases ***
    ${result}=    Set Variable If    '${text1}' in '${text2}'    ${TRUE}    ${FALSE}

Above code is giving error as Evaluating expression failed: SyntaxError: invalid syntax (, line 1)

Single quote is causing this issue, but I dont want to change variable value and evaluate them as they are. Replacing with double quotes is also not working and giving same error.

Can some one suggest how to evaluate this?

question from:https://stackoverflow.com/questions/65935411/evaluating-a-expression-in-quotes-failing-in-robot-framework

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can directly use robot variables in expressions by removing the curly braces from the variable name.

${result}=    Set Variable If    $text1 in $text2    ${TRUE}    ${FALSE}

This is covered in the BuiltIn Library documentation under a section called Evaluating Expressions


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...