If statement 如何应用If,Else条件在“RobotFramework”和“Sikulibrary”中的两个图像?
示例:单击应用程序图标后,会出现登录屏幕(If statement 如何应用If,Else条件在“RobotFramework”和“Sikulibrary”中的两个图像?,if-statement,robotframework,sikuli,If Statement,Robotframework,Sikuli,示例:单击应用程序图标后,会出现登录屏幕(login\u screen.png),有时会在登录屏幕前弹出一个OK对话框(OK\u btn\u dialog.png),如果出现OK对话框,我想单击OK按钮(OK\u btn\u dialog.png),然后继续登录屏幕(login\u screen.png),否则它将从登录屏幕继续(login\u screen.png) 如何在RobotFramework和sikulibrary中应用If,Else条件?使用这两个图像 这里有一个答案,但这不完全是
login\u screen.png
),有时会在登录屏幕前弹出一个OK对话框(OK\u btn\u dialog.png
),如果出现OK对话框,我想单击OK按钮(OK\u btn\u dialog.png
),然后继续登录屏幕(login\u screen.png
),否则它将从登录屏幕继续(login\u screen.png
)
如何在RobotFramework
和sikulibrary
中应用If,Else条件?使用这两个图像
这里有一个答案,但这不完全是我的问题。有一个
存在
,它将告诉您屏幕上是否存在图像。在可由运行关键字使用的正确/错误回答中,如果:
这可以实现为一个单独的关键字,它将单击图像(如果存在),否则将忽略
*** 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}
有一个Exists
,它将告诉您屏幕上是否存在图像。在可由运行关键字if
使用的真/假响应中:
这可以实现为一个单独的关键字,它将单击图像(如果存在),否则将忽略
*** 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\u btn\u dialog.png
而不是some\u image.png
,如果ans是yes,那么我会使用点击关键字来点击ok\u btn\u dialog.png
对不起,它不适合我:(,我已经尝试了这两种方法,它执行Run关键字If
关键字,但没有检测到图像,进入下一步,在关键字中添加了超时参数。步骤的顺序可能太快。因此,添加一些等待时间以允许“确定”按钮出现。它是否在图像出现时找到图像?它总是像e没有图像。我会使用ok\u btn\u dialog.png
而不是some\u image.png
,如果ans是yes,那么我会使用点击关键字来点击ok\u btn\u dialog.png
对不起,它不适合我:(,我已经尝试了这两种方法,它执行Run关键字If
关键字,但没有检测到图像,进入下一步,在关键字中添加了超时参数。步骤的顺序可能太快。因此,添加一些等待时间以允许“确定”按钮出现。它是否在图像出现时找到图像?它总是像e没有图像。