How to variabilize a VARIABLE NAME with Robot Framework

问题描述 投票:0回答:1

我目前正在使用这个循环:

@{someList}=    Create List    A    B    C    D    E
FOR    ${j}    IN    @{someList}
        FOR    ${i}    IN RANGE    999999
            ${randomString}=    Generate Random String    4    0123456789
            Set Suite Variable    ${nameItem${j}}    ${randomString}
            Set Suite Variable    ${refItem${j}}    ${randomString}/${date}
            ${myItem}=    GET    ${urlAPI}${urlItem}/${refItem**${j}**}
            ${condition}=    Run Keyword And Continue On Failure
            ...    The randomString number does not exist
            IF    "${condition}"=="True"    BREAK
        END
    END

我需要动态生成变量名,通过连接项目的名称和列表中的另一个名称。 我面临的问题是循环本身与 VSCode 上的 Robot 一样工作正常,但我必须复制 SquashTM 中的代码,这将导致消息错误,因为变量格式(Squash 只接受字母,数字和参数名称中的破折号)。

因此,由于 SquashTM,我必须重新编写代码才能更改变量名称。我仍然需要动态设置名称,因为我会在代码后期重用主题。

如何连接 2 个字符串以形成动态变量 name?我试图制作一个特定的关键字但没有成功。我是菜鸟所以有时我不明白事情是如何运作的!此外,由于我公司的政策,我无法安装其他自动化工具。

提前感谢您的帮助。

python testing automated-tests robotframework
1个回答
0
投票

您可以使用 Catenate

${new_var}    Catenate    SEPARATOR=    ${string1}    text1    ${string2}    text2
© www.soinside.com 2019 - 2024. All rights reserved.