【问题标题】:RobotFramework: Can not leave the error message if the element is not existRobotFramework:如果元素不存在,则无法留下错误消息
【发布时间】:2015-11-24 12:56:10
【问题描述】:

robotFramework 测试用例:

verify that user can send a request and redirect to next page
    Wait until element is enabled    ${errorCodeMessage}
    Element Text Should Be    ${errorCodeMessage}    Vikailmoituksen tapahtumat

输出日志:

Send request with 'Proprietary Tag' field :: OK: User is able to s... | FAIL |
Element locator '//h2' did not match any elements after 5 seconds

当元素不存在时,如何返回错误消息(例如:“此页面上没有此类元素”)? 而不是这个:"Element locator '//h2' did not match any elements after 5 seconds"

【问题讨论】:

  • 我不知道robotFramework,但通常您会使用try/catch 来捕获NoSuchElement 异常并将自定义消息写入日志。
  • @JeffC:这不是你在机器人框架中的做法。

标签: python selenium wait robotframework


【解决方案1】:

根据文档,wait until element is enabled 接受错误消息作为参数。所以,它看起来像这样:

Wait until element is enabled    ${errorCodeMessage}
...    error=There is no such element on this page 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-27
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 2017-11-19
    相关资源
    最近更新 更多