Sum of two variables in RobotFramework

I have two variables:

${calculatedTotalPrice} = 42,42 ${productPrice1} = 43,15 

I performed

 ${calculatedTotalPrice} Evaluate ${calculatedTotalPrice}+${productPrice1} 

I got

 42,85,15 

How can I solve it?

+5
source share
1 answer

By default, variables are strings in Robot. So your first two statements assign you strings like "xx, yy". Then "evaluate" just fulfill your statement, as Python would do. So, adding two lines with commas, you get a list:

 $ python >>> 1,2+3,4 (1, 5, 4) 

Therefore, you must use numeric variables using $ {} and. (dots) for the separator, as in this example:

 *** Test Cases *** sum of variables ${calculatedTotalPrice} = set variable ${42.42} ${productPrice1} = set variable ${43.15} ${calculatedTotalPrice} = Evaluate ${calculatedTotalPrice}+${productPrice1} log to console ${calculatedTotalPrice} 

This will give: $ pybot test.robot

 ============================================================================== Test ============================================================================== sum of variables ...85.57 ============================================================================== 
+10
source

All Articles