我有这些变量:
*** 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)
*我也尝试删除'-signs *
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}
。将来我想doc_types
为 if-else 添加更多证书和更多证书,这就是为什么我需要让这个东西像这样运行。