机器人框架字符串库中"Generate Random String"关键字,用于分配给变量



我需要生成随机数并将其分配给变量一次,以便以后多次使用它。我找到了关键字Generate Random String但我不知道如何将其应用于我的情况。

下面是

一个示例:

*** 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}

以及执行它时得到什么:

[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
[...]
另一个

执行将生成另一个随机数:

[MBP]$ pybot ts.txt
[...]
login with random string                                              .
attempting to log with login login and password 88780307
login with random string                                              | PASS |
------------------------------------------------------------------------------

最新更新