Forum Discussion

julie_mcmanus's avatar
julie_mcmanus
Occasional Contributor
11 years ago

Name Mapping

Using TC 8.70.727.7



I'm mapping controls from a control panel in my application (right click in object browser - Map Object...) , the panel is named 'CrownControls' in my application.  In the object browser it is named 'WinFormsObject("CrownControls") 

Sometimes a control on this panel gets mapped as 'CrownControls\mapped name'

Other times it gets mapped as 'wndCrownControls\mapped name'.  



I can't figure out why this happens or how I can specify exactly how it gets mapped.  Can you help?



I've attached a screenshot of the mapped objects.  TC seems to only see either one or the other at any one time.





7 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    In our case, we finally figured out that the application does change it.  In my example above, the UI loads first and then the data behind it.  When the UI first loads, the box in question is a text box.  As the data loads in the page, the box changes to a combo box.  



    It will always eventually change to a combo box, but we don't have a way to predict when that will happen in different environments because we could have very little data or we could have a lot of data.



    Now that we know it will always change, we could update our test to Wait for the combo box to occur.  We built the test with two mappings and IfObject when we didn't know what was happening other that it was changing sometimes.  That's why I suggested that solution for you.  If you can figure out why/when it's changing, then you can probably be more specific and use a Wait.
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    We have some fields that change state as the data loads into the UI.  They start out as text boxes and then change to combo boxes.  What we ended up doing was mapping the field both ways.  In the test, first we check for the text box, and if that's found, do the actions, and next we check for the combo box and if that's found, do the actions.  



    It might be better to do a WaitProperty of some sort, but since we're doing the same action either way, for us, it doesn't matter which kind of box it is at the time, just that we can get to it.









  • julie_mcmanus's avatar
    julie_mcmanus
    Occasional Contributor
    Thanks for the reply, I'm not sure this is the same issue.



    I have mapped some objects (they have been mapped to 'wndCrownControls' (from the example) then at a later time when I load the project and right click the object in the mapping editor to 'highlight on screen' or 'view in object browser' it says the object does not exist (although it does).  If I then find the object in the object browser and map it again it will map it to 'CrownControls' (from the example) which forces me to have to map all the objects again.  At a later time the mapping seems to revert back to the original mapping and I have to go through the process again for any objects that I have mapped in the meantime.



    It seems that either 'wndCrownControls' or 'CrownControls' only exists at any one time.  I suppose the question is - What is the sensible way to get around this and why does this happen? 
  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3
    If you have both wndCrownControls and CrownControls mapped, then check for both right in a row: 



    IfObject wndCrownControls Exists

      do some actions

    IfObject CrownControls Exists

      do some actions





    If only one of the objects exists at a time, then only one of those IfObjects will be executed and the other one will be skipped.  You don't really care which one it's doing. 



    Alternatively, you can map it once and change the mapping to have a wildcard so that anything that looks like *CrownControls goes to the same mapping.  I'm not sure that will work for you with the other things you need to map, but I know the IfObject will work.
  • If you check property NativeClrObject.Name for AudioArchitect.wndCrownControls, i believe it has same value as AutioArchitect.CrownControls has. Obviously AutioArchitect.CrownControls can map more controls because it has looser constraints.



    You should check value for WndCalss and WndCaption when it says AudioArchitect.wndCrownControls does not exist, to see which value is different.



    If AutioArchitect.CrownControls and AudioArchitect.wndCrownControls are referening to same object in your tested applicaiton, i would suggest you remove one of them because we no need to maintain two copies of name mapping for same object.



    Of couse you need to correct you name nampping by:

    1. Use properties that do not change during running

    2. Use wildcard in your mapping (e.g. WndClass=WindowsForms*)

    3. Use conditional filter in your mapping (e.g. WndCaption=abc or WndCaption=def)

    4. Use Required Children if controls that we can't tell apart contain different child controls



    -Ocean
  • julie_mcmanus's avatar
    julie_mcmanus
    Occasional Contributor
    Thanks for the replies.

    Using IfObject is an option which means I don't have to change the name in the script but it is not the full solution.



    I still have the issue when mapping the name in the first instance, it will map it to one and not the other (because it does not exist).  So I can map all the names  (say they get mapped to CrownControls when mapping from the object browser) but then if at a later date the object browser does not 'see' CrownControls I then have to remap the objects to wndCrownControls.  I don't know what causes the panel name as seen by test complete to change from time to time.  Could it be my application causing this?
  • julie_mcmanus's avatar
    julie_mcmanus
    Occasional Contributor
    Thanks Marsha.

    I don't think that's whats happening for me.  Its either one or the other, no matter how long I wait.  I'm now begining to wonder if it is something that has changed in my application between builds.  I need to investigate this further.  If I come to any conclusion I'll post an update.