Forum Discussion

yaacovk's avatar
yaacovk
Contributor
10 years ago

how to find an object by WndCaption property

Hi,

In my application I have to catch error message in order to close them for continue the script.

I choose several properties that caracterize these error message, but Test complete point on several objects that fill only a part of requirement.

For instance, script below (in jscript):

 

var PropArray = ("WndClass", "WndCaption", "Visible");
 var ValArray = ("FXTopWindow", "Error message", true);
 var error = Sys.Process("<application process name>").FindAllChildren(PropArray, ValArray, 3);
 var error = (new VBArray(error)).toArray();

 

for (var i=0; i<error.length; i++)
        Log.Message(error[i].FullName);

 

Assuming that 2 windows error are displayed (in my scenario), Script Test Log will display lot of windows that don't contain Caption "Error message".

Below some results displayed in Script Test Log, during this scenario:

 

Sys.Process("<application process name>").Window("FXTopWindow", "Error message", 1)

Sys.Process("<application process name>").Window("FXTopWindow", "<Parent Object WndCaption>", 51).Window("FXWindow", "", 1).Window("FXWindow", "", 1)

Sys.Process("<application process name>").Window("FXTopWindow", "<Parent Object WndCaption>", 51).Window("FXWindow", "", 5).Window("FXWindow", "", 1)

 

Two last objects displayed in this example have empty WndCaption in their properties.

In conclusion, I want to know how to filter these last objects and to obtain only object with WndCaption "Error message".

 

Regards

Yaacov

 

  • I found the mistake in my script:

    I need to define PropArray and ValArray as array:

    var PropArray = new Array ("WndClass", "WndCaption", "Visible");
     var ValArray = new Array("FXTopWindow", "Error message", true);

  • I found the mistake in my script:

    I need to define PropArray and ValArray as array:

    var PropArray = new Array ("WndClass", "WndCaption", "Visible");
     var ValArray = new Array("FXTopWindow", "Error message", true);

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hi,

    Try the following function that you could find an implementation in SmartBear's samples in your install :

     

    WaitAliasChild()

    • yaacovk's avatar
      yaacovk
      Contributor

      WaitAliasChild requires to map the specified object. Because there are a lot of Error messages in the application, I prefer to use FindAllChildren to ensure if any message with this caption ("Error message") appears.

      I want also understand why some objects not expected (without this catpion) are displayed.