gpt4 book ai didi

selenium - 如果单元格的 xpath 不匹配,如何忽略从单元格获取表格文本

转载 作者:行者123 更新时间:2023-12-02 22:12:56 25 4
gpt4 key购买 nike

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

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

最佳答案

使用运行关键字并在失败时继续运行关键字并忽略错误可以帮助解决此问题。在 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

关于selenium - 如果单元格的 xpath 不匹配,如何忽略从单元格获取表格文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47446777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com