【问题标题】:How to ignore Get Table Text from Cell, if xpath of cell not match如果单元格的 xpath 不匹配,如何忽略从单元格获取表格文本
【发布时间】:2018-05-06 21:42:51
【问题描述】:

如果单元格的 xpath 不匹配,如何忽略从单元格获取表格文本?因为我希望我的测试用例仍然继续测试。

 ${tableFinal}    Set Variable   xpath=/html/body/div[2]/div[3]/div/form/table[3]
 ${totalPayAmount}      Get Table Text from Cell     ${tableFinal}         1   2

谢谢你

【问题讨论】:

  • 您是否尝试过使用内置关键字“运行关键字并忽略错误”或“运行关键字并在失败时继续”
  • 谢谢你,它正在工作

标签: selenium automated-tests robotframework qa


【解决方案1】:

使用Run Keyword And Continue On FailureRun Keyword And Ignore Error 可以帮助解决这个问题。在documentation 全族Run Keyword .... 关键字中。

两者的区别在于,一个只是返回值,而另一个还提供了关键字执行的状态。

*** Test Cases ***
Test Case
    ${CoF_Pass_1}    Run Keyword And Continue On Failure    KW Pass
    ${CoF_Fail}      Run Keyword And Continue On Failure    KW Fail
    ${CoF_Pass_2}    Run Keyword And Continue On Failure    KW Pass

    ${IE_Pass_1}    Run Keyword And Ignore Error    KW Pass
    ${IE_Fail}      Run Keyword And Ignore Error    KW Fail
    ${IE_Pass_2}    Run Keyword And Ignore Error    KW Pass 

*** Keywords ***
KW Pass
    [Return]    SomeRandomValue
KW Fail
    Fail    SomeFaileMessage

这会导致:

Starting test: Test Case
INFO : ${CoF_Pass_1} = SomeRandomValue
FAIL : SomeFaileMessage
INFO : ${CoF_Fail} = None
INFO : ${CoF_Pass_2} = SomeRandomValue
INFO : ${IE_Pass_1} = ('PASS', u'SomeRandomValue')
FAIL : SomeFaileMessage
INFO : ${IE_Fail} = ('FAIL', u'SomeFaileMessage')
INFO : ${IE_Pass_2} = ('PASS', u'SomeRandomValue')
Ending test: Test Case

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-18
    相关资源
    最近更新 更多