我有以下变量:
*** Variables ***
${current} ""
${doc_type} ""
${document_type} ""
${HoiProo} Hoist\'s Proof Loading Certificate
${HoiMacIns} Hoisting Machinery Inspection Certificate
${inspection_certificate} Certificate.InspectionCertificate
${test_certificate} Certificate.TestCertificate 和这个关键字:
*** Keywords ***
Set Doc_type
${doc_type} = Set Variable If
... '${current}' == '${HoiProo}' ${test_certificate}
... '${current}' == '${HoiMacIns}' ${inspection_certificate}
Set Suite Variable ${document_type} ${doc_type}整件事
Setup current
${current} ${HoiMacIns}
Setup Doctype
Set Doc_type,但我不明白为什么机器人总是给我这个错误:
Evaluating expression ''Hoisting Machinery Inspection Certificate' == 'Hoist's Proof Loading Certificate'' failed: SyntaxError: invalid syntax (<string>, line 1)*我也尝试删除‘-标志*
Set Doc_type
${doc_type} = Set Variable If
... ${current} == ${HoiProo} ${test_certificate}
... ${current}' == ${HoiMacIns} ${inspection_certificate}
Set Suite Variable ${document_type} ${doc_type}把它打出来
Set Doc_type
${doc_type} = Set Variable If
... ${current} == Hoist\'s Proof Loading Certificate ${test_certificate}
... ${current}' == ${HoiMacIns} ${inspection_certificate}
Set Suite Variable ${document_type} ${doc_type}如果${current}是${HoiProo},那么${doc_type}应该是${test_certificate}。这个流程的工作原理是我已经测试过只比较${HoiMacIns}。将来,我想为if- doc_types添加更多的证书和更多的doc_types,这就是为什么我需要像这样运行这个东西。
发布于 2019-08-14 12:36:50
在使用表达式时,您必须记住,在机器人替换变量之后,表达式是有效的语法。如果变量包含Hoist's,并且尝试使用像'${HoiProo}'这样的表达式,机器人将创建像'Hoist's'这样的表达式,这是无效的语法。
解决这一问题的最简单方法是对表达式中的变量使用特殊的语法。如果省略花括号,机器人将直接使用表达式中的变量,从而消除了进行任何额外引用的需要。
例如:
${doc_type} = Set Variable If
... $current == $HoiProo ${test_certificate}
... $current == $HoiMacIns ${inspection_certificate}所有这些都被记录在BuiltIn库文档中名为评价表达式的部分中。
https://stackoverflow.com/questions/57493501
复制相似问题