Novari-QA's avatar
Novari-QA
Frequent Contributor
7 years ago
Status:
New Idea

NameMapping have "Required Parent" feature

Currently parent objects that have children have the ability to set a rule to have a "Required Children" field. 
However in our case, we have a panel that potentially can have children. These children are dynamic. and can be in 2 different locations.

My issue is that since the children are dynamic i cannot link them to the parent. Since I cannot link them to the parent the application can locate weither they are in Object A or Object B.

If i say Aliases.browser.page.objectA.dynamicObject.Click it clicks the object not problem. however, if i move that object to the other object via drag and drop or just moving it or what ever, if i say  Aliases.browser.page.objectA.dynamicObject.Click, it will still click the object. Even though it is located under objectB. this is because when testComplete looks at the object it doesn't care about its parent it only cares weither it found the same type of object. I have no fields to state that it is apart of a parent, so if i could say "required parent" then it would make my job easier.

6 Comments

  • cunderw's avatar
    cunderw
    Community Hero

    Aliases are just that, aliases. The actual mapping will require the dynamicObject to be a direct child of whichever parent object you have it mapped under. Unless you have extended find enabled which will then find the object on any level of the object tree. 

     

    For your behavior to work like expected you need to change the parent in the Mapped Object Panel in your name mapping, not in the Aliases section.

     

    Aliases don't care at all about hierarchy of the actual objects, they are used to make your mapped object more readable.

    So you can take something like Sys.Browser.Page.panel.panel.panel.button and reference it simply by Aliases.page.button. Aliases are like assigning variables to the full path. 

  • Novari-QA's avatar
    Novari-QA
    Frequent Contributor

    Yes i can asure you my issue is not a matter of simply understanding name mapping vs mapped objects.


    Object A and Object B holds identical objects called Object X. 
    Object X is defined by a project variable.

    The issue is that Object X can only exsist in either Object A or Object B, never at the same time.
    So when I say, ObjectA.ObjectX.DragTo(ObjectB). (image that function exsists). then ObjectX is no longer a child of ObjectA. Rather it is now a child of ObjectB. However When I say ObjectB.ObjectX.DragTo(ObjectA) it can't find the object. But if i say, ObjectA.ObjectX.DragTo(ObjectA) it will drag from ObjectB to ObjectA

    Again image that the DragTo function is a thing. The fact that the syntax and theory regarding "Dragging" is not the problem. The problem is that the child of object B is never being found but ObjectA is hanging onto an object that no longer is a child of that object.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    The NameMapping engine does not work in reverse... hence you can't say "using this Child, make sure it belongs to a particular parent".  This is why required children works because it finds a child object by the properties then checks to see if it has the required children.  The engine works it's way from the lowest ancester (Sys) up to the child object by finding each child based upon properties.  

     

     

    The problem you described above is really no problem at all.  After your first drag from A to B, call Page.RefreshMappingInfo to clear the internal cache of the mapped objects and then call your drag from B to A.  The mapping can stay as you described above, it's just a matter of clearing the internal cache of TestComplete so that it can find the objects according to the appropriate hierarchy again.

  • cunderw's avatar
    cunderw
    Community Hero

     Novari-QA - Apologies, I misunderstood your first post and what you mean by drag and drop (I thought you meant rearranging things in your mapping editor, not on screen dragging / dropping).

    tristaanogre - You beat me to the follow up :)

  • Novari-QA's avatar
    Novari-QA
    Frequent Contributor

    tristaanogre

    Yes i have tried this method. No luck unfortunately. 

    In my issue, im telling it to grab the object with variable Y but it is still trying to grab an object with variable X.

    Perhaps that is the issue. But in theory i think it shouldn't ever find the object since i am telling it to look under object A but it is grabbing it under object B

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    It's probably a combination of things...  the caching having it being found by the wrong thing and perhaps something incorrect in your code concerning changing the value of the variable before you attempt to interact with the mapped object.

     

    Suffice it to say, what you're suggesting in this feature request pretty much, as best as I understand it, violates the entire functionality of the NameMapping engine.  To map an object based upon it's parent which the engine uses in the first place to find the object itself... yeah, that's a recursive loop that just gives me a headache thinking about it.

    Perhaps it would be better, rather than continuing this conversation as part of a feature request, you post the problem to the main forums so folks can help you figure out how to resolve your problem.