【问题标题】:How to apply If, Else condition in `RobotFramework` with `SikuliLibrary` by two image on RIDE?如何通过 RIDE 上的两个图像在“RobotFramework”和“SikuliLibrary”中应用 If、Else 条件?
【发布时间】:2018-12-07 14:38:10
【问题描述】:

示例:点击应用图标后会出现一个登录屏幕(login_screen.png),有时会在登录屏幕之前弹出一个确定对话框(ok_btn_dialog.png),如果是确定对话框出现我想点击确定按钮(ok_btn_dialog.png)然后继续登录屏幕(login_screen.png),否则它将从登录屏幕继续(login_screen.png)。

如何在RobotFrameworkSikuliLibrary 中应用If, Else 条件?通过在 RIDE 上使用这两个图像。

这里有一个答案,但我的问题并不完全是answer

【问题讨论】:

    标签: if-statement robotframework sikuli


    【解决方案1】:

    有一个Exists keyword 会告诉您屏幕上是否存在图像。 This results 在真/假响应中,Run Keyword If keyword 可以使用:

    *** Settings ***
    Library    SikuliLibrary
    
    *** Test Cases ***
    TC
        ${exists}    Exists    ./some_image.png
        Run Keyword If    "${exists}"=="true"    Run True Keyword
        ...    ELSE IF    "${exists}"=="false"   Run False Keyword
        ...    ELSE                              Run Error Keyword   
    

    这可以实现为单独的关键字,如果存在则单击图像,否则将忽略。

    *** Settings ***
    Library    SikuliLibrary
    
    *** Test Cases ***
    TC
        # Check if button exist and retry for 2 seconds returning false.
        Click If Exists    ./ok_btn_dialog.png    ${2}
        Click             ./login_screen.png
    
    *** Keywords ***
    Click If Exists
        [Arguments]    ${image}    ${timeout}=${0}
        ${exists}    Exists    ${image}    ${timeout}
        Run Keyword If    "${exists}"=="true"    Click  ${image} 
    

    【讨论】:

    • 我会用ok_btn_dialog.png 代替some_image.png,吗?如果答案是肯定的,那么我使用Click 关键字点击ok_btn_dialog.png
    • 对不起,它不适合我:(,我都试过了,它执行Run Keyword If关键字,但没有检测到图像,进入下一步
    • 为关键字添加了超时参数。步骤顺序可能太快。因此,添加一些等待时间以允许出现“确定”按钮。
    • 当图像存在时,它会找到图像吗?
    • 它总是表现得好像没有图像。
    猜你喜欢
    • 2019-05-01
    • 2019-12-28
    • 1970-01-01
    • 2016-07-15
    • 1970-01-01
    • 2019-04-25
    • 1970-01-01
    • 2022-01-18
    • 2018-04-01
    相关资源
    最近更新 更多