Forum Discussion

googleid_111811's avatar
googleid_111811
New Contributor
12 years ago

Name mapping is missing, everytime the code is executed


I am testing and exe by writing scripts, which is a windows based application. I need to remap all the objects everytime I run the program.

My script is as below :



function main ()

{

TestedApps.StaadFoundation.Run();



var staadFoundation;

  var afx;

  staadFoundation = Aliases.StaadFoundation;

  afx = Aliases.StaadFoundation.Item_27.Afx;

  afx.ClickItem("Home|File|&Open");

  var fileName = "E:\\Documents\\StaadFoundation\\Models";

  var fileNameArray = GetFilesInFolder(fileName);

 

  for(var iFile=0;iFile<fileNameArray.length;iFile++)

  {

    var StaadFoundationfileName = fileNameArray[iFile];

   

     Log.Message("File Name :  " + StaadFoundationfileName);

     staadFoundation.dlgOpenProject.OpenFile("E:\\Documents\\StaadFoundation\\Models\\"+StaadFoundationfileName) ;

     afx.ClickItem("Home|Design / Analysis|Design / Analysis");

     

  }



"Aliases.StaadFoundation.Item_27.Afx" --> the item name is changing everytime .




An error occurred while calling the "ClickItem" method or property of the "Afx" object.

The object or one of its parent objects does not exist.



Tested Object














Alias:

Aliases.StaadFoundation.Item_27.Afx

Mapping item:

NameMapping.Sys.StaadFoundation.Item_27.Afx


Missing Object














Alias:

Aliases.StaadFoundation.Item_27

Mapping item:

NameMapping.Sys.StaadFoundation.Item_27

 






Please help me to resolve the name mapping isuue ASAP, as I am just a novis user of Test Complete. I could not solve the matter by using any help given antwhere.
  • vajindarladdad's avatar
    vajindarladdad
    Frequent Contributor


    Hi,

    Not sure how did you map the objects & what all properties your have selected to identify the object uniqly.

    Please try to the following method



    For NameMapping.Sys.StaadFoundation.Item_27.Afx:

    If there is property which has something mentioned with number please replace the [only]number with the "*" so that it will work whenever you run the project.



    For Aliases.StaadFoundation.Item_27.Afx

    Check the selected property which you have used for identification.

    Also please show us the snapshot of Aliases.StaadFoundation.Item_27.Afx object , so that we will come to know what all properties you have mentioned to identify this object uniquely.

    If the selected property keeps changing everytime you run the project , follow the below mentioned method





    Below explanation is just a copy-paste from TC help file:

    The names that TestComplete gives by default to test objects (processes, windows and controls) are a combination of various object properties that specify the object type and contents. These names are good unique identifiers of the objects among their siblings. However, these names may be long or hard to understand. For instance, it may be difficult to understand which text box on screen corresponds to a name like Sys.Process("MyApp").Window("MyFormClass", "Input Order", 1).Window("TextEdit", "", 2).

    So, the TestComplete engine lets you assign custom names to processes, windows, controls and other objects, or, in other words, you can map an object to another name. The two main benefits of there feature include - -

    Making your keyword tests and scripts shorter and more readable (a custom name, say, EditorWindow is shorter and more user-friendly than Sys.Process("Editor").Window("Editor", "*", -1)).

    Making keyword tests, scripts and the object names independent on object properties, which may change from one application build to another.

    To create a custom name for an object, use the NameMapping project item. It acts as a collection of name mapping settings, that is, it defines which custom name corresponds to which object.

    When mapping the object’s name to a custom one, you specify properties and their particular values which are used to identify this object. For instance, you can assign the mapped name notepad to the Process("notepad") whose Name property is notepad and Index is 2. These properties and their values are stored in the corresponding name mapping item along with the custom object name. TestComplete then uses these properties to recognize the mapped object during test recording and playback.



     


  • As I am  new here, so please specify exactly how the "*" should be used, as while I am replacing the number with asterix character, it states that invalid syntax is used.



    also I am attaching the snapshots of the steps for mapping the object using object spy.
  • Hi Vajindar Laddad,

    Thanks for your previous reply. I tried the solution given by you but that doesn't solve my problem yet. So, I posted all the related things you asked for.



    I would highly appreciate if you could please help me to olve my situation at the earliest.



    Thanks in advance.