Forum Discussion

anilcharan's avatar
anilcharan
Occasional Contributor
14 years ago

Export Name Mapping file to spread sheet

Hi,



    Iam using TestComplete 7.52version. I want to export the Name Mapping item of my Project Suite to any spread sheet. I require this to implement Key-word testing for my application. In addition to that, i want to know is there any way to open the Name Mapping item and with what type of application should i open incase it can be opened.



Regards,

Anil.

9 Replies

  • anilcharan's avatar
    anilcharan
    Occasional Contributor
    Hi Artem,



            Thank you for your reply. 



            I require the existing "Name Mapping" item in a Project to be exported to a "Spread sheet(MS Excel)" document. I want to export the Object Properties(Ex:- page, panel, form, table,and so on...) that exist in Name Mapping item to an MS Excel sheet. I need to export the file from Test Complete to outside MS Excel Sheet. Looking for a great help.





    Regards,

    Anil.

  • Hi Anil,

    Thanks, now I get your idea. Currently, name mapping data cannot be exported to any other formats. We have the corresponding feature request in our DB, and your post has increased its rating.

    Sorry for the inconvenience.
  • anilcharan's avatar
    anilcharan
    Occasional Contributor
    Hi Artem,



            Thanks Artem, for considering this feature request and please let me know when the request is completed.



    Thanks,

    Anil.




  • I came across a similar problem when working on implementing an automation framework:

    http://community.smartbear.com/forum/post/?mode=singleThread&thread=d117d8f0-c2c5-4e2e-abcd-4bbf6896a94c



    One thing that can be used is that all the mapped objects, whether they are on screen or not, include properties that match the name of their children. So you can iterate through the properties, filter out common ones, and crawl through the name mapping with them.



    This is a really ugly approach that I came up with. Apologies for the awkwardness. It just posts the info to the log, which you can copy and paste into Excel to delete extraneous columns.





    '////////////////////////////////////////////////////////////////////////

    '

    '  Service           : ExportAliasesTree().

    '

    '  Abstract          : Exports a list of all the aliases defined in the project.

    '                      This only works if the mapped objects are not currently

    '                      displayed, so mapped application(s) are automatically

    '                      closed.

    '                      The alias tree is shown in the log.

    '

    '  Inputs and Type   : None.

    '

    '/////////////////////////////////////////////////////////////////////////

    Sub ExportAliasTree()

        

      ' BEGIN

      Options.Run.Timeout = 1

      Call GetNextAlias(Aliases, "Aliases")

      Options.Run.Timeout = 10000

        

    End Sub ' ExportAliasTree



    '////////////////////////////////////////////////////////////////////////

    '

    '  Service           : ExportNameMappingTree().

    '

    '  Abstract          : Exports a list of all the mapped objects in the project.

    '                      This only works if the mapped objects are not currently

    '                      displayed, so mapped application(s) are automatically

    '                      closed.

    '                      The name mapping tree is shown in the log.

    '

    '  Inputs and Type   : None.

    '

    '/////////////////////////////////////////////////////////////////////////

    Sub ExportNameMappingTree()



      ' BEGIN

      Options.Run.Timeout = 1

      Log.AppendFolder("Name Mapping")

      Call GetNextAlias(NameMapping.Sys)

      Log.PopLogFolder

      Options.Run.Timeout = 10000



    End Sub ' ExportNameMappingTree



    '////////////////////////////////////////////////////////////////////////

    '

    '  Service           : GetNextAlias().

    '

    '  Abstract          : Exports the name of an alias object or name mapping

    '                      object to the test log, then is recursively called for

    '                      all children of that object.

    '

    '  Inputs and Type   : AliasObject: The object to log.

    '                      strAliasObjectName: The mapped name of the object to log

    '

    '/////////////////////////////////////////////////////////////////////////

    Sub GetNextAlias(AliasObject, strAliasObjectName)



      ' local variables

      Dim iteratorProperties ' Group of all properties of the object to log

      Dim iteratorProp ' Current property of object to log



      ' BEGIN

      Set iteratorProperties = aqObject.GetProperties(AliasObject)



      While iteratorProperties.HasNext  

        Set IteratorProp = iteratorProperties.Next

        If (iteratorProp.ValueType = 29) Then

          Select Case iteratorProp.Name

            Case "Exists","NamedChild","NamedChildCount","NodeDescription", _

              "_NewEnum","ChildCount","Clipboard","CPU","CPUCount", _

              "CPUUsage","Desktop","DomainName","FullName","HostName","Id", _

              "MappedName","MemUsage","Name","OleObject","OSInfo","Parent",_

              "UserName","CommandLine","VMSize","AccessibilityObject",_

              "SynchRoot", "placeholder"

            Case Else

              Call Log.AppendFolder(strAliasObjectName & " " & _

                iteratorProp.Name,iteratorProp.Name)

              If aqObject.GetPropertyValue( _

                aqObject.GetPropertyValue(AliasObject, _

                  iteratorProp.Name),"Exists") = True Then

                  aqObject.GetPropertyValue(AliasObject, _

                    iteratorProp.Name).Terminate      

              End If ' aqObject.GetPropertyValue

                Call GetNextAlias(aqObject.GetPropertyValue(AliasObject, _

                  iteratorProp.Name),iteratorProp.Name)

                  Call Log.PopLogFolder

          End Select ' iteratorProp.Name   

        End If ' (iteratorProp.ValueType = 29)

      Wend ' iteratorProperties.HasNext    

       

    End Sub ' GetNextAlias

  • anilcharan's avatar
    anilcharan
    Occasional Contributor
    Hi Andrew,



            Thank you for finding some kind of solution for the above issue. I will go through this code and implement in my case and let know about the execution of the script.





    Thanks,

    Anil.
  • anilcharan's avatar
    anilcharan
    Occasional Contributor
    Hi Andrew,



            I gone through the code. The "ExportAliasTree()" is working fine where as the "ExportNameMappingTree()"  is throwing an error. Please find the attached Error image. Looking for your great help.





    Thanks,

    Anil.
  • anilcharan's avatar
    anilcharan
    Occasional Contributor
    Hi Andrew,



                The issue was identified and changed the necessary code to run the script effectively.



    In "ExportNameMappingTree()",



    we have 4th line as  "Call GetNextAlias(NameMapping.Sys)".



    Please change the above piece of code to " Call GetNextAlias(Aliases, "NameMapping.Sys") ".



    Then, the script executed well.





    Thanks,

    Anil.


  • Thanks Anil for finding that. The forum interface won't let me go back to revise the code sample.



    As you can obviously tell from your experience, I haven't used the snippet for exporting the Name Mapping in some time. The reason for that was that we found the best way (in our case) to use abstract object references from our framework with TestComplete was to rely mostly on Aliases.



    The framework we implemented was constrained to only use 2 abbreviated text identifiers to identify a given object. This was perhaps excessively primitive.



    For an example object, such as Aliases.App1.Obj1.Obj2.Obj3, we needed to write code in TestComplete so that we could find it with just Obj1 and Obj3.



    The most stable approach was to use Find() or FindChild() to look for an object that had MappedName = "*Obj1*Obj3" - which works for all objects in the Name Mapping with or without an alias - but this was very slow in execution, taking 7-9 seconds to identify each object.



    WaitAliasChild() returns much faster, but requires more error checking, and it requires that you follow more strict rules in the mapping of the application to aliases. Even so, we find that identifying objects from the primitive references is the biggest bottleneck we have in execution performance.