机器人框架如何验证窗口中元素的值

时间:2017-04-05 11:52:54

标签: selenium robotframework

enter image description here

我想验证价值' Ping信息为'它存在于窗口中。

1 个答案:

答案 0 :(得分:0)

您可以创建自己的关键字,以检查给定定位器的文本是否与预期的字符串值相等

To Verify Text
  [Arguments]      ${locator}    ${expectedString}
  ${Somevariable}=    Get Text     ${locator}
  Should Be Equal       ${Somevariable}      ${expectedString}

此处Should Be Equal来自built in库,Get Text来自selenium2library。

参考链接:http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Should%20Be%20Equal http://robotframework.org/Selenium2Library/Selenium2Library.html#Get%20Text