如何在机器人框架中始终满足条件的情况下循环?

时间:2019-06-22 03:25:29

标签: robotframework

我使用robotframework和appium进行UI自动化,当打开应用程序时,它将弹出不同的弹出窗口(如更新版本,重复登录等),我想要一个条件始终为true的循环,在此循环中可以在我看到弹出窗口取消按钮后立即单击它,直到所有弹出窗口消失并且我不需要关心弹出窗口的顺序 我该如何在robotframework中做到这一点?

我不会降低弹出窗口的顺序,所以有时我找不到元素,当前的解决方案是我多次使用for循环,但这并不是最好的方法

:FOR  |  ${i}  |  IN RANGE  |  2

    \    ${binaryPopStatus}  |  Run Keyword And Return Status   | Page Should Contain Element  |  &{locator_binary_popup_close_btn}[${PLATFORM}]

    \    Run Keyword If |   '${binaryPopStatus}'=='True'  |  Click Element  |  &{locator_binary_popup_close_btn}[${PLATFORM}]

    \    ${sysPopStatus} |   Run Keyword And Return Status  |  Page Should Contain Element  |  &{locator_sys_popup}[${PLATFORM}]

    \    Run Keyword If  |  '${sysPopStatus}'=='True'  |  Click Element |   &{locator_sys_popup_deny}[${PLATFORM}]

    \    ${versionPopStatus}  |  Run Keyword And Return Status  |  Page Should Contain Element  |  &{locator_version_popup_cancel}[${PLATFORM}]

    \    Run Keyword If  |  '${versionPopStatus}'=='True'  |  Click Element    |&{locator_version_popup_cancel}[${PLATFORM}]

    \    ${locationPopStatus}  |  Run Keyword And Return Status  |  Page Should Contain Element  |  &{locator_enable_location_popup_notnow}[${PLATFORM}]

    \    Run Keyword If  |  '${locationPopStatus}'=='True'  |  Click Element  |  &{locator_enable_location_popup_notnow}[${PLATFORM}]

    \    ${enjoyPopStatus}  |  Run Keyword And Return Status  |  Page Should Contain Element    |id=com.sixdays.truckerpath.dev:id/rate_app_not_now

    \    Run Keyword If  |  '${enjoyPopStatus} '=='True'  |  Click Element |   id=com.sixdays.truckerpath.dev:id/rate_app_not_now

    \    ${loggedPopStatus}  |  Run Keyword And Return Status  |  Page Should Contain Element  |  &{locator_logged_cancel_btn}[${PLATFORM}]

    \    Run Keyword If  |  ${loggedPopStatus}  |  Click Element  |  &{locator_logged_cancel_btn}[${PLATFORM}]

0 个答案:

没有答案