【发布时间】:2017-10-27 05:05:46
【问题描述】:
我是 Robot Framework 的新手,我正在尝试使用 Run Keyword If .. ELSE ..。
应该怎么做:
添加新关键字以检查页面是否包含“已关闭”一词。如果是,请刷新页面。如果没有,请单击元素“this”并继续该场景的其余部分。
*** Keywords ***
Check if anything is closed
${ClickThis} Click Element xpath=//*[@id="this"]
${Closed} Page Should Contain Element xpath=//*[text()='Closed']
Run Keyword If ${Closed} =='PASS' Reload Page ELSE ${ClickThis}
当我运行它时会发生什么:
“已关闭”不会出现在页面中。点击“这个”。然后测试失败,因为:Page should have contained element 'xpath=//*[text()='Closed']' but did not
请帮我纠正它。
编辑:将 Page Should Contain 更改为 Page Should Contain Element。结果相同。
【问题讨论】:
标签: robotframework