Ask a Question

If statement for VisibleOnScreen is failing when object is not on screen

SOLVED
Mark1
Contributor

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

10 REPLIES 10

The only issue with this is, I dont expect the dialog box to appear every time I run the test, in fact I would say it only appears maybe 1 in 20 runs. So writing code around triggering it to  appear and then waiting to make sure it exists before clicking the button wont really work. All I need is if  the diaglog box is visible then click the ok button, else  carry on as normal. Its like a pop up warning ,you just click ok and move on.

 

Edit: After looking into some simple name mapping I managed to get it to work using your earlier code. I will definently be speaking to the project manager about implementing name mapping as it could have saved me a lot of time if we had been using it from the begining. I appreciate your help very much.

cancel
Showing results for 
Search instead for 
Did you mean: