Testing &引用;“生成随机字符串”;Robot框架字符串库中用于分配变量的关键字

Testing &引用;“生成随机字符串”;Robot框架字符串库中用于分配变量的关键字,testing,random,automation,robotframework,browser-automation,Testing,Random,Automation,Robotframework,Browser Automation,我需要生成随机数,并将其分配给变量一次,以便以后多次使用。我发现关键字生成随机字符串,但我不知道如何将其应用于我的案例。以下是一个示例: *** Settings *** Library String *** test cases *** login with random string ${password} = Generate Random String 8 [NUMBERS] login to system login ${password} *** Ke

我需要生成随机数,并将其分配给变量一次,以便以后多次使用。我发现关键字
生成随机字符串
,但我不知道如何将其应用于我的案例。

以下是一个示例:

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

为什么生成随机字符串不合适?哦,我的意思是我不知道如何应用它。对不起)好吧,那你的情况如何?你能把你到目前为止试过的东西贴出来吗?通常,您只需将该关键字的输出分配给一个变量,并像往常一样使用该变量。因此,
${random strig}生成随机字符串
我想创建一个具有随机密码的用户,将其分配给变量,然后使用此密码登录。