我在测试用例中有如下2个关键字
Wait Until Page Contains Element 'Error element' timeout= 200
Wait Until Page Does Not Contain Element 'Error element' timeout=100
即使错误没有出现在第一个关键字上,我也希望测试继续。
我尝试了以下 2 个选项,但它对我不起作用。 选项 1:
Run Keyword And Ignore Error Wait Until Page Contains Element 'Error element' timeout= 200
Wait Until Page Does Not Contain Element 'Error element' timeout=100
选项2:
${Ignore_Error} Wait Until Page Contains Element 'Error element' timeout= 200
Run Keyword And Ignore Error ${Ignore_Error}
Wait Until Page Does Not Contain Element 'Error element' timeout=100
我还尝试过 Run 关键字并在失败时继续,但这对我来说也不起作用
有什么建议吗?
提前致谢。
您是否尝试过运行关键字并期望错误内置关键字?例如:
*** Test Cases ***
My test
Open Browser url=https://www.google.com/ browser=firefox
Run Keyword And Expect Error * Find my element
Close Browser
*** Keywords ***
Find my element
Wait Until Page Contains Element //input[@value="Bing Search"]
在示例中,元素
//input[@value="Bing Search"]
在 Google 搜索页面上不可见,并且 Run Keyword And Expect Error *
匹配任何错误/字符串。因此,此关键字预计会出现任何错误,并且测试用例会通过。希望这有帮助。