Forum Discussion

Mojo's avatar
Mojo
Occasional Contributor
7 years ago
Solved

How to make recognition index generic?

Hi all,

   I am using a keyword driven descriptive framework. All the recognition are kept in an external file like notepad, excel etc. 

Here i have a recognition of a window object as follows:

Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation", 1)["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysListView32", "", 1)

 

Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation", 2)["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysTreeView32", "", 1)

 

In the above two recognition, you can see the index of the ("Afx:*", "Production * - IO-Allocation", 1) has changed from 1 to 2.

How to make this generic so that i do not have to use two different recognition.

  • Current:

    Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation", 2)["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysTreeView32", "", 1)

     

    Can you try like this,

    Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation")["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysTreeView32", "", 1)

3 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Current:

    Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation", 2)["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysTreeView32", "", 1)

     

    Can you try like this,

    Sys["Process"]("SmAlloc")["Window"]("Afx:*", "Production * - IO-Allocation")["Window"]("AfxMDIFrame110u", "", 1)["Window"]("SysTreeView32", "", 1)

    • Mojo's avatar
      Mojo
      Occasional Contributor

      Thank you Shankar, its working fine. Can you please explain the logic behind this ? Will be really greatfull

      • shankar_r's avatar
        shankar_r
        Community Hero

        The logic behind this,

         

        ["Window"]("Afx:*", "Production * - IO-Allocation", 2)

         

        Here, "Afx*" is the mandatory parameter that TestComplete expects other two are optional hence Object is getting identified without index.

         

        From TestComplete Document


        TestObj.Window(WndClassWndCaptionGroupIndex)

        TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
        WndClass [in]    Required    String    
        WndCaption [in]    Optional    String Default value: *   
        GroupIndex [in]    Optional    Integer Default value: -1   
        Result A Window object

        https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/window-method.html