If statement for VisibleOnScreen is failing when object is not on screen
I have a method where if the a specific dialog box is VisibleOnScreen it will click the ok button and carry on else it just carries on as normal. This dialog box is just a warning that the software being tested was closed incorrectly last time it was used. It not guaranteed to show up every time you run a test but it will only ever appear at this one specific time I run this method.
The issue occurs when the dialog box does not appear but since I have a variable which is set to that dialog box, if gives an error since it couldnt get the dialog box and carries on with the rest of the test. How do I get around this issue. Here is an example of what I mean.
Sub OKClick
Set DialogBox = Sys.Process("softwareBeingTested")....etc
If DialogBox.VisibleOnScreen Then
'click ok button
Else Log.Message "No dialog box appeared
End If
End Sub