简体   繁体   中英

How to parse variables in Robot Framework

I have a variable with value "x: 647, y: 1174" and I would like to parse them into two separate variables: ${x} = 647 and ${y} = 1174

Is this possible within Robot Framework?

String library will help you.

${var}    Set Variable    x: 647, y: 1174
${x}    Fetch From Left    ${var}    ,    # now x should be "x: 674"
${x}    Fetch From Right    ${x}    ${SPACE}    # and now it should be "674"
${y}    Fetch From Right    ${var}    y:${SPACE}

Or write a python function that does the same with regex for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM