Forum Discussion

HD's avatar
HD
Contributor
11 years ago

Namemapping nightmare

Hi,



I am new to Testcomplete and having trouble with namemapping. I am using Testcomplete to test a WPF based application. The issue is that UI on the application keeps changing, and each time I have to update the namemapp as well as the tests that use onscreen actions. This is a nightmare as it takes a lot of time, and most of my time is spend on updating namemapping and the tests.



1) Namemap is like a tree, so if something is added near the root then I need to remapp all the child nodes even when they did not change. There is no mechanism to copy paste the nodes or to insert a node in between the tree. Is there a workaround or feature to do this easily?



2) Also, even after updating the namemapping I need to update the refereneces in the tests and onscreen actions. Is there a better way to do it?



Is there a better alternative to namemapping or a better way to handle this scenario?
  • Forget name mapping and use small scripts that search your entire app for the object you need, sending as parameters the properties they have, for example (this works for me because i'm testing a webapp, but I think it works for anything):



    function clickObject(propName, propValue,depthOfSearch)

    {

        Sys.Process("yourApp").FindChild(propName,propValue,depthOfSearch).click(0,0);

    }



    Now you can use this for any action your object supports, use object spy to see all the details about the object you're looking for.



    This solves your issue because it always finds your object, unless their properties change, wich they shoudn't.



    Name mapping is only usable if your app will never change, otherwise you need to take a crash course on how to be able to configure it to work with wildcards and stuff....
  • HD's avatar
    HD
    Contributor
    Thanks guys for helping me out.



    I took Jose's suggestion and now I am using a mixed approach.



    1) For features in my application where UI keeps evolving I implemented a script to find UI objects and perform on screen actions.



    2) For features that don't change that often, I use Namemapping.



    I will gradually replace operations involving namemap with the script.
  • rgratis's avatar
    rgratis
    Frequent Contributor








    Jose Pita



    "R. Gratis


     


    If you decide to write script functions to find the objects for you, you can always move them out into a Script Extensions Runtime Object, which can make them much like Aliases in TestComplete.  I've done this on a few different products to allow sharing the functions between multiple TestComplete Projects."



    Yesterday I was investigating this option but I found some forum entry saying that you can't debug \ catch errors from Script Extensions. Haven't tried it yet, but I don't think I'm willing to.





    I write in VBScript, so I use VBScript's native error handling mechanism to catch exceptions inside the Script Extension code.  If an exception makes it through, it pops up an exception window during a TestComplete run.  I can get the line number / unit in the Script Extension from the popup text, but that same information doesn't make it into the TestComplete log Call Stack, so if you're trying to fix an issue in an unattended test run that you can't replicate locally, it can be difficult.  It certainly makes you write defensive code.











  • HD


    Thanks guys for helping me out.



    I took Jose's suggestion and now I am using a mixed approach.



    1) For features in my application where UI keeps evolving I implemented a script to find UI objects and perform on screen actions.



    2) For features that don't change that often, I use Namemapping.



    I will gradually replace operations involving namemap with the script.




    HD: one question.

    Did you compare the speed of your automation test after applying "search" at step 1 above against the speed by using name mapping you implemented previously? Does "always search" slow down your test?



  • I tried this findchild method as described by Joel and ran into a problem.



    Specifically, if something fails, it will fail in the script routine at the line that's supposed to actually click the item.



    Clicking on the failure in the test log WITHOUT this script will jump to the line in the keyword test that actually failed.

    Clicking on the failure WITH the script just shows you the script line, which is very generic.

    The log doesn't tell you what it was trying to click at the time...



    It makes the tests a bit easier to write, but a lot harder to debug, as far as I can tell.



    How did you all get around that?
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Joseph,



    Don't double-click on the log record but instead switch to the Call Stack pane of the log (usually it is below main log grid). Double-click on the call stack record will navigate you to the relevant line and this greatly simplifies debugging.
  • Ah, I see.

    Well, while I was trying to figure out what to do about this, I figured out some stuff about how to create custom messages using event handlers.



    I now have messages that read: "Clicked <item identifier> " instead of "The window was clicked with the left mouse button"



    And  failures that read: "Failed to click  <item identifier> " instead of "You tried to click something that doesn't exist."



    Should make the failure logs a bit easier to follow, and using the stack to get back to the actual failing line item will make troubleshooting easier.



    So... learned two things today, not just one.  Thanks.