Frameworks 对具有特殊字符的字符串进行条件处理

Frameworks 对具有特殊字符的字符串进行条件处理,frameworks,conditional,robotframework,Frameworks,Conditional,Robotframework,我遇到了一个不寻常的情况,当我的字符串中有一个撇号,需要执行“run关键字if”条件。下面是我的代码: *** Variables *** ${myVar} = Joe's test *** Test Cases *** Testing a true IF statement Run Keyword If '${myVar}' == 'Joe's test' Keyword 1 *** Keywords *** Keyword 1 Log to Console VAL

我遇到了一个不寻常的情况,当我的字符串中有一个撇号,需要执行“run关键字if”条件。下面是我的代码:

*** Variables ***
${myVar} =  Joe's test

*** Test Cases ***
Testing a true IF statement
    Run Keyword If  '${myVar}' == 'Joe's test'  Keyword 1

*** Keywords ***
Keyword 1
    Log to Console  VALUE: ${myVar}
我得到以下错误:

Evaluating expression 'Joe's test == 'Joe's test'' failed: SyntaxError: invalid syntax (<string>, line 1).
计算表达式“Joe's test==”Joe's test“”失败:语法错误:无效语法(,第1行)。
我尝试使用像\'这样的开关来处理字符串中的撇号,但仍然没有成功。感谢您的帮助

使用双引号:

run keyword if  "${myVar}" == "Joe's test"  keyword 1
run keyword if  '''${myVar}''' == "Joe's test"  keyword 1
如果
${myVar}
可能包含单引号或双引号,则可以使用三引号:

run keyword if  "${myVar}" == "Joe's test"  keyword 1
run keyword if  '''${myVar}''' == "Joe's test"  keyword 1