Search code examples
robotframework

In Robot Framework, How Can I change the value of my variable it it's not a number


In Robot Framework, How Can I change the value of my variable it it's not a number.

I need help as it is resulting to an error

enter image description here

${deliveryfee} = Get Text xpath://[@class='open-page auto-expand-transition']//[@class='summary-row'][2]//*[@class='price total']

Run Keyword If ${deliveryfee} == "-" ${deliveryfee} = Replace String - 0.00 enter image description here


Solution

  • Two things: You need to have ${deliveryfee} in double quotes, and your code would look better if you used the new IF - END style:

    ${deliveryfee}=    Set Variable    -
    IF    "${deliveryfee}" == "-"
         ${deliveryfee}=    Replace String     ${deliveryfee}    -     0.00
    END