首页 > 解决方案 > 机器人框架:验证值大于 10 的最简单方法是什么

问题描述

所以有一个网站:https ://www.guruwatch.nl/Aandelen/Default.aspx

我单击元素“koop”,然后我想验证顶部的值是否大于 10

id="ctl00_ctl00_ContentPlaceHolder1_RightContent_ListAandelen_repAandelen_ctl01_lblCountBuy"

最快的方法是什么?

我用了

Element Text Should Be  ctl00_ctl00_ContentPlaceHolder1_RightContent_ListAandelen_repAandelen_ctl01_lblCountBuy  24

但那是为了完全匹配,我只想验证整数是否大于 10。

还有一个应该等于整数 first second
builtin

但不是 a 应该比整数大 应该比整数小

ps 为什么那些不是内置的?用这个有那么奇怪吗?

标签: robotframework

解决方案


* If有很多方法可以使用可以在内置库中找到的关键字来检查一个值是否大于另一个值。以下是如何制作大于关键字的示例:

*** Test Cases ***
Test Positive
    ${value}    Set Variable    24
    Should Be Larger Than    ${value}    1

Test Negative
    ${value}    Set Variable    24
    Run Keyword And Expect Error    *    Should Be Larger Than  ${value}    100


*** Keywords ***
Should Be Larger Than
    [Arguments]    ${value_1}    ${value_2}
    Run Keyword If    ${value_1} <= ${value_2}    
    ...    Fail    The value ${value_1} is not larger than ${value_2}

推荐阅读