mercredi 14 août 2019

It is not possible to have ' in a saved variable in Robot Framework?

I have these variables:

*** 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 

and this keyword:

*** Keywords ***
Set Doc_type
${doc_type} =  Set Variable If
    ...  '${current}' == '${HoiProo}'  ${test_certificate}
    ...  '${current}' == '${HoiMacIns}'  ${inspection_certificate}
    Set Suite Variable  ${document_type}  ${doc_type}

Whole thing

Setup current
  ${current}  ${HoiMacIns}
Setup Doctype
  Set Doc_type

But I don't understand why Robot keeps giving me this error:

Evaluating expression ''Hoisting Machinery Inspection Certificate' == 'Hoist's Proof Loading Certificate'' failed: SyntaxError: invalid syntax (<string>, line 1)

*I have also tried to remove '-signs *

Set Doc_type
${doc_type} =  Set Variable If
    ...  ${current} == ${HoiProo}  ${test_certificate}
    ...  ${current}' == ${HoiMacIns}  ${inspection_certificate}
    Set Suite Variable  ${document_type}  ${doc_type}

and to type it out

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}

If ${current} is ${HoiProo} then ${doc_type} should be ${test_certificate}. This flow works as I have tested to compare only ${HoiMacIns}. In the future I want to add more certificates and more doc_types for the if-else, that's why I need to have this thing run like this.

Aucun commentaire:

Enregistrer un commentaire