Example: After clicking on the app icon a login screen(login_screen.png
) appear, Sometimes one OK pop up dialog(ok_btn_dialog.png
) coming before the login screen, If the the OK dialog appear I want to click on the OK button (ok_btn_dialog.png
) then continue with Login screen(login_screen.png
) , otherwise it will continue from Login screen(login_screen.png
).
How to apply If, Else condition in RobotFramework
with SikuliLibrary
? by using those two image on RIDE.
One answer here, but it's not exactly answer of my question.
There is an Exists
keyword that will tell you if an image exists on screen. This results in a true/false response that can be used by the 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
This may be implemented as a seperate keyword which will click on the image if exists and otherwise ignores.
*** 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}