I need to generate random number and assign it to the variable once to use it multiple times later. I found keyword Generate Random String
but I don't know how to apply it for my case.
1 Answer
Here is an example:
*** Settings ***
Library String
*** test cases ***
login with random string
${password} = Generate Random String 8 [NUMBERS]
login to system login ${password}
*** Keywords ***
login to system
[arguments] ${login} ${password}
log to console \nattempting to log with login ${login} and password ${password}
and what you get when you execute it:
[MBP]$ pybot ts.txt
==============================================================================
Ts
==============================================================================
login with random string .
attempting to log with login login and password 30865042
login with random string | PASS |
------------------------------------------------------------------------------
Ts | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
[...]
another execution would generate another random number:
[MBP]$ pybot ts.txt
[...]
login with random string .
attempting to log with login login and password 88780307
login with random string | PASS |
------------------------------------------------------------------------------
${random strig} Generate Random String