如何在Robot Framework中的测试用例中使用TRUE和PASS值?

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

我是机器人框架的新手,所以我需要这方面的帮助,我正在尝试执行“RUN KEYWORD IF”,如果我查看他们提供的文档 运行关键字 If | '${状态}' == '通过' |一些操作arg

我的疑问是这个 PASS 值。如何得到这个,因为每次我尝试时,每个关键字语句都没有值。我正在尝试做这样的事情:

*** Settings ***

*** Variables ***
${name}      theon

*** Test Cases ***
Verify
    ${x}=    Set Variable    function
    Run Keyword If    '${x}==PASS'    Log 'True'
    ...    ELSE    Log    'False'

*** Keywords ***
function
    ${return}=    Should Equal    ${name}    theon
    [Return]    ${return}

我收到 x 被定义为 NONE 的错误,那么我如何在我的关键字成功或 True 的情况下进行验证。

我还想了解是否可以使用自定义关键字代替“条件”来运行某些关键字。

运行关键字如果||这里有一些 self 关键字,它返回我 pass 或 true||目标关键词

robotframework
2个回答
0
投票

应该等于有什么作用? 由于 RF 中不存在“Should Be Equal”,但这只是通过或未通过测试。 请注意所有应该...表现得像这样。 也许您想要评估是否

${name}

theon 相等(相同),然后使用 evaluate ... ${return}= evaluate '${name}'=='theon'

评估将返回 True 或 False

然后这就会起作用。

Run Keyword if ${x} Log True



0
投票

以下示例:

Run Keyword if ${medicine_expiry_year} > 2000 and ${medicine_expiry_year} < 2016 Send Mail to Company ${company_mail_id} Run Keyword if ${medicine_expiry_year} == 2016 Report Remaining Months to Store operator ${month_of_expiry} Run Keyword if ${medicine_expiry_year} > 2016 Log "Keep the medicine"

上例中的条件:

${medicine_expiry_year} > 2000 and ${medicine_expiry_year} < 2016 ${medicine_expiry_year} == 2016 ${medicine_expiry_year} > 2016

自定义关键字带参数:

使用关键字“send Main to Company”向公司发送邮件,邮件 ID 在“${company_mail_id}”中提供

Send Mail to Company ${company_mail_id}

使用关键字“Report the Remaining Months to Store Operator”报告剩余的存储月份运营商,使用变量“${month_of_expiry}”提供的到期月份

Report Remaining Months to Store operator ${month_of_expiry}

只需使用关键字记录消息

Log "Keep the medicine"

希望这对您有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.