Forum Discussion

vikram_u_k's avatar
vikram_u_k
Contributor
8 years ago
Solved

General best practice to map Objects in Hybrid Android Application

Hi Support/ TC users,

    I would request your views on the Best practice to use Flat  versus Tree Object mapping.

 

My observation so far is that there may be about 450 objects and this is favourable to both Tree as well as Flat mapping. However the flat naming will lead to increased access times rather than the tree format.

 

 

Any/All suggestions are welcome..

 

I have noted that in the example there are a lot of unnamed Layout's which could change in both tree/flat naming structure.

The screen layout and wireframes are already frozen but the type of controls are subject to change.

 

* using TC 12.10.602 on 4.4.3/Lollipop for API19.

  • Hi,

     

    As per http://support.smartbear.com/testcomplete/docs/testing-with/object-identification/default-naming/object-tree-models.html, Tree is the preferred and recommended model.

    As for the mapping approach for (hybrid) Android applications, personally I found nothing too different from what is used for desktop and web applications:

    -- If UI of the tested application is frozen and you namemap all objects that are used in tests, then do this. And consider more convenient/simplified Aliases tree to make your test code more readable and short;

    -- If it is not possible to namemap all tested objects, then create a set of core ones that are used as stable 'anchors' where dynamic search of the child objects starts from;

    -- Do not forget about 'Extended Find' namemapping option, but do not use it to search for the objects that are deep down the hierarchy as this decreases the performance;

    -- Also, TC 12 (if I remember version correctly) introduced a new parameter that makes it possible to specify object's search strategy - breadth-first or depth-first. You may play with this to improve the performance.

     

    So... Nothing really special as I said.

    Have you met something unusual that was the reason for your question?

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    As per http://support.smartbear.com/testcomplete/docs/testing-with/object-identification/default-naming/object-tree-models.html, Tree is the preferred and recommended model.

    As for the mapping approach for (hybrid) Android applications, personally I found nothing too different from what is used for desktop and web applications:

    -- If UI of the tested application is frozen and you namemap all objects that are used in tests, then do this. And consider more convenient/simplified Aliases tree to make your test code more readable and short;

    -- If it is not possible to namemap all tested objects, then create a set of core ones that are used as stable 'anchors' where dynamic search of the child objects starts from;

    -- Do not forget about 'Extended Find' namemapping option, but do not use it to search for the objects that are deep down the hierarchy as this decreases the performance;

    -- Also, TC 12 (if I remember version correctly) introduced a new parameter that makes it possible to specify object's search strategy - breadth-first or depth-first. You may play with this to improve the performance.

     

    So... Nothing really special as I said.

    Have you met something unusual that was the reason for your question?

    • vikram_u_k's avatar
      vikram_u_k
      Contributor

      Many thanks Alex,

           True that the tree layout is more flexible when seen in light of the unnamed Layout_No_ID(1,2,3,4) as seen in my screenshot.These Layouts as they are unnamed now will not fit in the flat layout.

       

      I am using the aapt dump tool to get the list of resources( which reads the list of resources from *.xml in APK) file and map them to the mapped objects so that we have full traceability of the object map.

       

      Please provide details about using this:  Also, TC 12 (if I remember version correctly) introduced a new parameter that makes it possible to specify object's search strategy - breadth-first or depth-first. You may play with this to improve the performance.

       

      I am trying to map the layouts as sub frames in a webpage so that we could visualize the tree by DOM or using LinkText as supported in Selenium.

       

      regards,

      Vikram U

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi Vikram,

         

        > Please provide details about using this: [...]

        Not sure what details you are talking about as I believe that help topic describes it...

        In a nutshell, in order to find an object of the tested application, TestComplete traverses object's tree. Tree traversal can be done in two ways: either 'horizontally' (in breadth) - layer by layer, or 'vertically' (in depth) - branch by branch. Whatever way is more efficient depends on the object's tree and where within the tree the sought for object is. So, as the help topic suggests, if you observe slow object search, you may try to change search strategy and check if it helps.

         

        > or using LinkText as supported in Selenium.

        Again, I am not sure what the problem is here... Just a personal opinion that I consider object's search capabilities in Selenium to be quite limited and the most people I listened to were saying that search by LinkText is one of the least recommended approaches...