cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the EXISTS method in TestComplete V9

Highlighted
Occasional Contributor

Problems with the EXISTS method in TestComplete V9

I had some issues with the EXISTS method in terms of dealing with modal lists of an application (test object). Somehow the EXISTS method may not deliver the correct information, whether the object is available or not. In terms of misleading information the test process may run into an error.

 

I found a solution based on AliasObjects and direct accessing of the list.

 

---------------------------------------------------------------------------------------------------------------------------

 

Sub selectList (Caption, Action)

Dim Selection

' Define object
' If it is available, Selection contains the object otherwise an empty object
' WNCode is just a variable to cover several versions of the test object without
' the need of code adaptation

 

Set Selection = Sys.Process("za").WaitWindow("FNWNS"+WNCode,Caption,-1,1000)

 

' a mixture of AliasObjects |-> Aliases.za.wndSelect...| and
' direct coding |-> Sys.Process("za").WaitWindow("FNWNS"+WNCode...|
' of the GUI objects avoids / bypasses
' the weakness of the EXISTS method in the TestComplete V9
' the following lines work: it deals with no, one or multiple list(s), which
' may occur whilst user interaction

While (Aliases.za.wndSelect.Exists)
    ' Exists works solely fine with the AliasObjects!

     Aliases.za.wndSelect.SetFocus
     Aliases.za.wndSelect.Keys(Action)
     Set selection = Sys.Process("za").WaitWindow("FNWNS"+WNCode,Caption,-1,1000)

Wend

 

End Sub

--------------------------------------------------------------------------------------------------------------------

Thank you in advance.
Best regards
Torsten
4 REPLIES 4
Highlighted
Occasional Contributor

Re: Problems with the EXISTS method in TestComplete V9

wndSelect has to be defined in the NameMapping section within the project.

Thank you in advance.
Best regards
Torsten
Highlighted
Community Hero

Re: Problems with the EXISTS method in TestComplete V9

Your problem is in the following line

 

While (Aliases.za.wndSelect.Exists)

 

The Exists property MAY work fine for this in some situations... but it will generally fail.  The reason being is actually logically simple: you cannot check the "Exists" property of an object that doesn't exist... you must have an object to have the "Exists" property.  Usiing Aliases works best because some of that is taken care of within the NameMapping engine.

 

The best way to check the existance of an object you've already demonstrated in your code: Use a "Wait" method of some sort.  So, I would actually change your line of code to something like this.

 

While (Aliases.za.WaitAliasChild("wndSelect", 10000).Exists)

 

Reference the following help topic.

https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html#che...

 


Robert Martin
[Hall of Fame]
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
Highlighted
Occasional Contributor

Re: Problems with the EXISTS method in TestComplete V9

Hello.

 

In fact, I thought the same concerning the EXISTS method whilst my trying with several code alternatives. I also used the WaitAliasChild. But I might be working almost correct. Thus I wil try your proposed solution.

 

Thank you for your hint.

Thank you in advance.
Best regards
Torsten
Highlighted
Occasional Contributor

Re: Problems with the EXISTS method in TestComplete V9

Hello. 

 

Yes, ist works! Thank you.

Thank you in advance.
Best regards
Torsten
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors