我正在创建一个新脚本,其中更改了设置然后保存。选择保存按钮后,屏幕将自行屏蔽,并在页面右下角显示一条请稍候...消息。我希望我的脚本等待此消息不再显示,然后注销。我看到的当前行为是脚本继续执行并在显示等待消息时选择注销按钮。
我正在使用 RIDE 来编辑我的脚本,它看起来像这样:
Click Element id=save
Wait Until Keyword Succeeds 30 sec 1 sec Page should not contain element xpath=//*[text()='Please wait…']
${Status} Run Keyword and return status Page Should Not Contain Element xpath=//*[text()='Please wait…']
Run Keyword If ${Status}=="True" Click Element id=logout
这个测试用例运行成功,没有错误。它只是不等待页面完成更新和保存新设置。
请您参考如下方法:
问题很可能是您的应用在“请稍候”消息出现之前花费了数百毫秒。因此,当关键字运行到页面不包含该元素时,关键字会立即退出,因为它还没有出现在页面上。
一个简单的解决方案是等待它出现,然后再等待它消失:
Wait Until Page Contains element xpath=//*[text()='Please wait…'] timeout=5
Wait Until Page does NOT contain element xpath=//*[text()='Please wait…'] timeout=30
