Forum Discussion

rafiqque's avatar
rafiqque
Occasional Contributor
14 years ago

Is it possible to add Aliases from code

Hi,

I have used name mapping and aliases. It is done in design mode. i.e. run the required application and use TC to browse its objects and map the necessary objects. 



Is it possible to add these aliases or create aliases while running the TC script. Like run a script which loads the desired application and returns me the process handle. Using this process I can navigate to the desired menu object and screen objects and map them in the scripting code.



Well the reason for this is I am trying to map objects its too time consuming as my application has many many fields and around 200 screens. 



And one more question suppose I map all these 200 screens using name mapping and write my test case scenarios which will be around 300 plus. How will be the performance of TC will it slow down because of too many objects in name mapping.

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    As far as I am aware, NameMapping only impacts performance on load time, before the script execution actually starts.  So you may see some delay between starting your tests and the execution of the first testing step.



    As for adding NameMapping at runtime, you can do so, however I don't have a lot of experience with it.  You cannot, as far as I can tell, add Aliases, but you can add NameMapping items.  See http://smartbear.com/support/viewarticle/12464/



    However, given that you need to know the items already (SysNode), this will take some programming to be able to map all your stuff programmatically.  I'm not sure how much time saving this will be for your situation.
  • Hi Rafiq:



      You can skip system object mapping mechanism to have you own object mapping design, but you need to design first.



      We are facing same problem. In my case, I have to do GUI and functional testing at same time for almost 800 screens application. So, I designed a framework to handle many layers of information such as keyword driven test case, object mapping, data driven by data table and configuration.



       So far I can tell is the Framework runs perfectly and no performance issues with it.

      

      The big problem is screen objects change will stop test case running and we are looking for best solution for it.



    Good luck,



    Allan



       
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Allan is referencing the use of methods like FindChild and FindAllChildren which are excellent programmatic ways for finding components and objects.  They don't add the objects to NameMapping but they do search the hierarchal tree of objects to find the specific object based upon a set of properties and values.  As mentioned, this takes some design work because you need to know the sets of properties and values to use for finding objects.  Data driven work with external files (like CSV or XML) can help with this so you don't have to "hard code" in your tests the specifics but you can build your mapping structure externally.



    Many ways to skin the same cat... :-)
  • rafiqque's avatar
    rafiqque
    Occasional Contributor
    Hi, 



    Thanks for the reply. 



    1. Name mapping is a good feature but only problem is, if I create a name mapping with only NativeClrObject. (That is what I get when I run record and play). Name as search criteria at times my object search fails. So even if the object is loaded, still I get a response of object not found error. When I debugged from the node object and drilled down to child/child ... hierarchy the object is there still I use to get this error. But if give multiple search criteria like "clrClassName, Name and Index, then I am not facing such errors. So to map each object with these criteria has become more time consuming for me.



    2. As as framework goes, I am trying to develop a framework like this.

    Each screen becomes a ODT class.

    Entry Fields and verification fields become its properties

    so these properties will have the Alias name mapping as their values 

    eg.

    Field:  EmployeeNo 

    Class Property: objEmployeeNo

      Value - "Aliases.MyApp.Startup.frmEmployeeDetails.txtEmployeeNo"

             Class Property: valEmployeeNo  this will hold the value of the employee no field during run-time



    Basic methods:

    LoadObject()  - which assigns the alias values to the properties.

    KeyInValue() - Will key in values passed as parameters to the respective entry field

    GetValue() - will assign values to the "val" prefixed properties like valEmployee the available value from the screen.



    So using these above methods the person who writes a test scenario can key in values and get values and compare it against expected values. And if there is a need one add further functions to this class based on the requirement (as you walk through your test case).



    3. While interpreting the manual test case, the test case entry data and verify data is passed through excel sheets.

    I have written a test case using these classes. It is running fine.

    So to pass data to the test case from excel, I created a dictionary object collection of the excel sheet and using it in my test case to get values. I am not sure it is a good idea. The reason I chose is I was going down several level of functions and wasn't sure how to pass the exel DDTs to them. So instead I create an instance of the collection and pass it where ever necessary.



    4. Still I have to cover a lot more 

    a. Capturing run-time errors both from TC and running application and acting on it.

    b. Function error wont be a problem as with the test case step I have success criteria. So I just have to pass or fail it.



    5. After the trouble with name mapping I decided to use the direct full name of the object to access it instead of Alias object. I am halfway into writing a program to generate these classes. 

    This I am doing it using a user form. which will show me all the entry fields of the selected screen. In addition I can point to more controls and add them to my list. Then finally generate the class code using the list of objects selected.

    I have already written a program to generate class for grids in my applications coz it is pretty simple as it has only navigate tool strip control, Save/Cancel tool strip and the grid.



    Any points or suggestions or even criticism is much appreciated.


















  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Name mapping is a good feature but only problem is, if I create a name mapping with only NativeClrObject. (That is what I get when I run record and play). Name as search criteria at times my object search fails. So even if the object is loaded, still I get a response of object not found error. When I debugged from the node object and drilled down to child/child ... hierarchy the object is there still I use to get this error. But if give multiple search criteria like "clrClassName, Name and Index, then I am not facing such errors. So to map each object with these criteria has become more time consuming for me.




    This is actually best practice, really, when using NameMapping.  To use only a single property for mapping, especially if there are multiple objects that may share that property value, is going to generate any number of problems with object identification.  The more properties you can use, the better chance of creating a unique mapping.  



    To help out with the mapping, you can create NameMapping templates that, when you map an object, it automatically selects certain criteria, speeding up your process.