如果单元格的xpath不匹配,如何忽略从单元格获取表文本 [英] How to ignore Get Table Text from Cell, if xpath of cell not match

查看:156
本文介绍了如果单元格的xpath不匹配,如何忽略从单元格获取表文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to ignore Get Table Text from Cell, if xpath of cell not match ? Becuase i want my test case still continues testing .

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

谢谢

推荐答案

使用Run Keyword And Continue On FailureRun Keyword And Ignore Error可以帮助解决此问题.在文档中,整个Run Keyword ....关键字.

Using either Run Keyword And Continue On Failure or Run Keyword And Ignore Error can help with this. In the documentation the entire family of Run Keyword .... keywords.

两者之间的区别在于,一个仅返回值,而另一个还提供了关键字执行的状态.

The difference between the two is that one just returns the value, whereas the other also provides the status of the Keyword execution.

*** 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

这篇关于如果单元格的xpath不匹配,如何忽略从单元格获取表文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆