我是Robot Framework的新手,我试图使用Run Keyword If .. ELSE ..
。Robot Framework运行关键字如果..否则失败
应该怎么做:
添加一个新的关键字来检查页面是否包含单词“closed”。如果有,请刷新页面。如果不是,请单击元素“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}
当我运行它,会发生什么:
“封闭”没有出现在页面中。 “this”被点击。那么测试失败,因为:
Page should have contained element 'xpath=//*[text()='Closed']' but did not
请帮我纠正它。
编辑:更改Page Should Contain
到Page Should Contain Element
。相同的结果。
它的工作就像一个魅力!谢谢你解释它。 – Tea000