Ask a Question

Problems with the EXISTS method in TestComplete V9

SOLVED
tziconsult
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
tziconsult
Occasional Contributor

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

Thank you in advance.
Best regards
Torsten
tristaanogre
Esteemed Contributor

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
tziconsult
Occasional Contributor

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
tziconsult
Occasional Contributor

Hello. 

 

Yes, ist works! Thank you.

Thank you in advance.
Best regards
Torsten
cancel
Showing results for 
Search instead for 
Did you mean: