cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting to continue with popup window

SOLVED
Contributor

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 testscript. I have wrote as below,

 

if Aliases.DataAcquisition.WinFormsObject("AutomatedStatusChangeUIControl").Exists Then
             Aliases.DataAcquisition.WinFormsObject("AutomatedStatusChangeUIControl").WinFormsObject("btnCancel").ClickButton
Else

 

Call Test 1

 

 end if

 

 

The problem here is that, if the "AutomatedStatusChangeUIControl" does now appear, its always giving an error. How can i make it skip the window popup can continue.

 

Thanks for  helping,

Sudha

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Scripting to continue with popup window

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/wa... 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

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

2 REPLIES 2
Highlighted
Community Hero

Re: Scripting to continue with popup window

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/wa... 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

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

View solution in original post

Contributor

Re: Scripting to continue with popup window

Thank you Robert Martin. Now its working as expected.