Forum Discussion

kandy1984's avatar
kandy1984
Contributor
6 years ago
Solved

Scripting to continue with popup window

Hi,   I am having trouble to write a vbscript which  checks if the pop-up window has appeared and then if its there, then click on "Cancel" button and if its not there, then procced to the next tes...
  • tristaanogre's avatar
    6 years ago

    This is a common mistake.  If you think about it, how do you check the "Exists" property of an object that does not exist?  If the object does not exist, it won't even have an "Exists" property.  So, you need to first attempt to locate the object.  That is done using either a Wait method or a Find method.  Taking your code from below, I would use WaitWinFormsObject (https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/waitwinformsobject-method.html).  HEre's how I'd change your code.

     

    if Aliases.DataAcquisition.WaitWinFormsObject("AutomatedStatusChangeUIControl", 5000).Exists Then
                 Aliases.DataAcquisition.WinFormsObject("AutomatedStatusChangeUIControl").WinFormsObject("btnCancel").ClickButton
    Else 
    
    Call Test 1
    
     end if