Forum Discussion

thexder1's avatar
thexder1
Contributor
12 years ago

Name mapping

Is there a way to create name mapping on the fly?



The scenario that I am running into is I have a WPF application where there is a job queue, For each job there is a button that can say start or pause. The problem that I am running into is it looks like all of the start buttons are mapped the same so if I try to target one it will not be unique enough to know which one to select. The only way that I can find to target it uniquely is to use a property called data context which is going to be different for each job. When looking at the object through object spy or name mapping editor the parent always looses connection.



When looking at the object path every start button is excatly the same even the properties other than the DataContext. The only way that I can think of to get this to work would be if there was a way to create a name map on the fly to target the DataContext.Name that is the same as the name of the job that is assigned to the job for the current iteration of a data-driven loop.

3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jeff,


     


    You need to create your own Name Mapping Template and make TestComplete use the DataContext.Name property to map your buttons. Read the "Name Mapping Templates" article for details.


     

  • I see where I can use name mapping to try to do what I am talking about, but anytime I point to anything below the top level properties ie. DataContext.Name TestComplete can no longer find the object.



    I have verified that I am entering the information exactly as shown in object spy but still cannot find it when putting that in the name mapping.  I get errors saying the name mapping is ambiguous and all I did for a test was go to conditional mode of the object I left the default property there which is ambiguous but does not give any errors and clicked the and button then selected [Type property name] and entered DataContext.Name, I then selected Equals for the condition, and for the value I entered test1 which is the name of a job that I currently have in the queue. When I click ok I get error saying that the name mapping is ambiguous and if I say yes then the name mapping for the object is broken until I remove the second property.



    So the first problem is how can adding an and to the conditional name mapping suddenly make it ambiguous? Especially since the default value that TestComplete picked is completely ambiguous, but does not give any errors indicating that.



    The second problem is why is the name mapping not reading the property that I entered correctly? I entered one of the few things that Object Spy shows as unique but the name mapping part does not see it that way. Why is there a difference between the two? How do I fix it?
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Jeff,


     


    We cannot tell you anything for sure without detailed investigation of your Name Mapping file. Could you please post it here or send your project to our Support team?