How to subtract the number in a Robot Framework? What is the command for it?
For example, if I am getting a count, I want to subtract -1 and map keywords with the resulting value.
If your variable contains an actual number, you can use extended variable syntax. For example, this test will pass:
*** Variables ***
| ${count} | ${99} | # using ${} syntax coerces value to number
*** Test cases ***
| Example
| | Should be equal as numbers | ${count-1} | 98
You can also use the Evaluate keyword to create a python expression. For example:
*** Variables ***
| ${count} | 99
*** Test cases ***
| Example
| | ${count}= | Evaluate | ${count} - 1
| | Should be equal as numbers | ${count} | 98
Note: using Evaluate will work whether ${count}
is a number or the string representation of a number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With