Forum Discussion

Mrunal's avatar
Mrunal
Contributor
9 years ago
Solved

How to make objects index dynamic

Hi,

 

I have two applications which performs same fuctions. I have same script for these two applications.

 

The only difference in these aplications is one more screen is Added in say app 2.

 

My code is as follows:-

 

App 1 with one extra screen:- 

Sys.Process("abc").SWTObject("Shell", "PCW").SWTObject("Composite", "").SWTObject("Composite", "").SWTObject("Composite", "", 1).SWTObject("Composite", "", 1).SWTObject("Composite", "", 4).SWTObject("PCC", "").SWTObject("Button", "Validate", 3)

 

 

App 2:- 

Sys.Process("xyz").SWTObject("Shell", "PCW").SWTObject("Composite", "").SWTObject("Composite", "").SWTObject("Composite", "", 1).SWTObject("Composite", "", 1).SWTObject("Composite", "", 3).SWTObject("PCC", "").SWTObject("Button", "Validate", 3)

 

How to make this one dynamic, so my script will run on both app with same index?

 

Thanks in Advance.

 

 

11 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Not knowing how complex is the overall structure of the given tested application but considering only the objects you've mentioned in the initial post, I would do it this way:

    -- Map the SWTObject("PCC", "") object. Agree when TestComplete suggests to map all SWTObject("Composite") parents;

    -- Select the 'Find object on any level of hierarchy' (or how it is called) checkbox in the lower-left corner of the mapping editor when mapping the SWTObject("PCC", "") object;

    -- Navigate to the NameMapping editor and delete all mapped SWTObject("Composite") objects between SWTObject("Shell", "PCW") and SWTObject("PCC", ""). Answer 'No' when prompted to delete the mapped object, so that TestComplete does not delete the mapping for the SWTObject("PCC", "")  object but moved it up one level;

    -- Finally, you should get a NameMapping tree with the SWTObject("Shell", "PCW")  object and the SWTObject("PCC", "") mapped as its direct child with the Extended Find checkbox selected;

    -- Navigate to the Aliases tree and check that that the Aliases tree has the same structure;

    -- With the PCC window opened on the screen, right-click the PCC object in the Aliases window and select the Highlight On Screen command. The target window must be identified and highlighted if everything was done correctly.

     

    With the above mapping, you should be able to address the PCC window in your test code in both applications with the line like this:

    Aliases.PCW.PCC

     

    Does this help?

    • Mrunal's avatar
      Mrunal
      Contributor

      Hi,

      Thanks for the suggestion.

       

      I will try to map objects manually as per your suggestion and will let you know.

    • Mrunal's avatar
      Mrunal
      Contributor

      Hi Colin,

       

      Thanks for suggestion.

       

      Will try it out and let you know.

      • Mrunal's avatar
        Mrunal
        Contributor

        Hi Colin,

         

        I tried with the way you suggested, but my test failed on both the apps.

         

        Error Details :- Object does not exists.

         

        Attaching screenshot here which contains - 1) Name Mapping 2) Error Details

         

        I may be wrong in implementing. Can you please help me?

         

        Thanks in Advance.