Forum Discussion

mathieuleb's avatar
mathieuleb
Contributor
10 years ago
Solved

Name mapping refresh problem

Hi, we use a custom control to handle different action base on the context.  Each control have a unique ID, but the name mapping doesn't seem to work correctly when we reuse a control.



ex:

Control1 in context X: ID 190014

Control1 in context Y: ID 30147



The problem is that, the name mapping always identify the object no matter if we are in context X or Y.



And if I add remove/add field in the name mapping editor, the value change..







  • If I'm understanding you correctly, you have 2 different IDs to identify the same object at different points. Name mapping allows that, but you need to enter Conditional Mode (the button on the lower-left) and construct the different variations. Once you've done that, it should work as expected.



    It makes sense when you think about it from TestComplete's perspective. You have an object on the screen identified by an ID. When the application changes the ID of the object (even if it's really the same object), TC doesn't see the object any more.



    The reason the ID changes when you re-add the property is because TC is populating the value with what's available at the time you map it. Apparently, that's different when you're re-adding vs when you mapped it originally.



    And you may already be doing this (or if I'm completely missing what you're saying), I always like to throw in a mapping refresh before I call something when objects change without a full page refresh:



    aliases.objectName.refreshMappingInfo

4 Replies

  • If I'm understanding you correctly, you have 2 different IDs to identify the same object at different points. Name mapping allows that, but you need to enter Conditional Mode (the button on the lower-left) and construct the different variations. Once you've done that, it should work as expected.



    It makes sense when you think about it from TestComplete's perspective. You have an object on the screen identified by an ID. When the application changes the ID of the object (even if it's really the same object), TC doesn't see the object any more.



    The reason the ID changes when you re-add the property is because TC is populating the value with what's available at the time you map it. Apparently, that's different when you're re-adding vs when you mapped it originally.



    And you may already be doing this (or if I'm completely missing what you're saying), I always like to throw in a mapping refresh before I call something when objects change without a full page refresh:



    aliases.objectName.refreshMappingInfo
  • You'll need to use a different propety to identify the object, rather than the id.



    If you have a controlled set of IDs being used, you could add a conditional value of "m_dwUniqueID = 30147 OR m_dwUniqueID = 190014. But if you have no control of the values assigned for the id, you're not going to be able to use that property to identify the object. 



    Or, if you don't have anything else with the same WndClass, you don't need the m_dwUniqueID property at all to identify the object.
  • Our tests work fine with the id most of the time.  Each action have it's ID.  But we have a control that can change of ID base on the context.



    The problem is a refresh in the name mapping.  The value are not supposed to change if I just remove and add it in the selected property
  • I missed the part about cached value in the name mapping.



    I thought it was like a debugger.  But if my control value field change, I need to manually refresh.



    Thanks!