I have two variables:
${calculatedTotalPrice} = 42,42
${productPrice1} = 43,15
I executed
${calculatedTotalPrice} Evaluate ${calculatedTotalPrice}+${productPrice1}
I got
42,85,15
How can I resolve it?
I have two variables:
${calculatedTotalPrice} = 42,42
${productPrice1} = 43,15
I executed
${calculatedTotalPrice} Evaluate ${calculatedTotalPrice}+${productPrice1}
I got
42,85,15
How can I resolve it?
You can also use inline Python evaluation.
*** Variables ***
${calculatedTotalPrice} ${42.42}
${productPrice1} ${43.15}
*** Test Cases ***
Add two variables
${sum} set variable ${{ $calculatedTotalPrice + $productPrice1 }}
should be equal as integers ${sum} ${85.57}
Check out the documentation here for more options.
Laurent's answer is almost always going to be the best course, but if for some reason you desire or require your Robot variables to be Strings that contain numbers, you can alternatively convert them to numbers inside of the Evaluate call:
*** Test Cases ***
Test1
${I1} = set variable 10
${I2} = set variable 5
${F1} = set variable 42.42
${F2} = set variable 57.15
${ISUM} = Evaluate int(${I1}) + int(${I2})
${FSUM} = Evaluate float(${F1}) + float(${F2})
log to console ${ISUM} ${FSUM}
This gives output:
Test1 ......15 99.57
By default variables are string in Robot. So your first two statements are assigning strings like "xx,yy" to your vars. Then "evaluate" just execute your statement as Python would do. So, adding your two strings with commas will produce a list:
So you should use number variables using ${} and . (dots) for separator like in this example:
This will produce: $ pybot test.robot