Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to subtract the Number in Robot framework?

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.

like image 755
Karthika Its Your Skills Avatar asked May 26 '15 11:05

Karthika Its Your Skills


1 Answers

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.

like image 172
Bryan Oakley Avatar answered Nov 24 '22 19:11

Bryan Oakley