How to use robot framework to check if the window exist

How can I let the robot knows if a window pop up in a desktop app, the robot should implement some command to close the window, and if the window doesn’t pop up we ignore it. The above picture is the window called ‘Select Services Required’ that I want the robot to tick the checkbox and close it if it pops up, but sometimes the window actually doesn’t pop up, so how can i set a if statement for this?

    Control Window    name:"Select Services Required"    id:frmJobEntryServiceType
    WINDOWS.Click    name:"Sea Freight" type:CheckBox
    WINDOWS.Click    name:Cancel

So the above codes are the code I want the robot to implement if the window pop up, now just want to know how to write a if statement to let the robot know if the window exists, pls run the code

You can use List Windows to get existing windows and then check if you new pop up is on that list. If present then you can perform specific actions.

The window doesn’t show after using the List Windows keyword, also the window doesn’t show in the task bar, so I use the Run Keyword And Return Status:

    ${status}    Run Keyword And Return Status    Get Element    	Select Services Required
    IF    ${status}
        WINDOWS.Click    name:"Sea Freight" type:CheckBox
    END

If the status return value is true, then it will implement the code, if not, just skip it

1 Like