Forum Discussion

srini_g_vasan's avatar
srini_g_vasan
Occasional Contributor
10 years ago
Solved

how to use same mapping for different run time objects.

Team,



On clicking a menu in application , new form will appear in my application. Each form has instance column to map the form to other component in my application. on form load instance column is -1 , I can set that to 1,2,3 etc to match to any external component.

I have created name mapping with property instanceid as -1. for first form I get the mapping object and store it in a js variable. Now I change the instance of the form to external component instance= 2 . Now i click a menu again new form get appeared , to refresh the mapping I m calling RefreshMappingInfo()on alaises. Now namemapping is pointing to new form.

But js variable in which I had old form instance is also

mapped to new form...I understand this is because of reference change.



But I need both the instance .



Is there any way in testcomplete to resolve this requirement.



Regards,

Srini
  • I think Checkpoints could help you out a lot. There are Property Checkpoints which let you check for different properties available for an object or child object. This may be the simplest to use.

    Then there are Region Checkpoints where you can capture an image, mask parts of it, compare the stored image with the newer image from playback etc. http://support.smartbear.com/viewarticle/57039/



    Since it sounds like you are needing the comparison more using a property checkpoint or region checkpoint may be the simplest to either script or keyword.

    If you use Keyword tests, you would get the object up to the point just before it changes, set the initial checkpoint, perform your next action which would change the form, then set the follow up checkpoint, then setup if statements after the initial checkpoint with the checkpoint as part of the requirements, have it perform the action, set another if statement with the follow up checkpoint as the requirement, then your next actions. 



    With script tests, I would functionalize the checkpoints have it return true or false, setup the initial checkpoint, setup an if statement with the checkpiont referencing the initial checkpoint, perform an action on true, exit program or loop on false, setup the follow up checkpoint, and repeat above.



    Hope this helps.

6 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor
    As I understood you have mapped common properties of set of objects.

    So all abjects are identified as one by TC



    How about mapping unique property or combination of properties?

    Some times the property you need may present at parent or child of the object you deal with
  • In a VB 6 program that I test, there are a few different objects like that, the 'technically' have the same properties except for one item and that is the label caption attached to the two objects that happen to be radial buttons.



    I am not sure if this helps you since you are dealing with table cells, may be use the columb and row, or some other property that is unique to each cell. if nothing else maybe re-record it using low level. I think this generates x, y coordinates that would be unique.
  • srini_g_vasan's avatar
    srini_g_vasan
    Occasional Contributor
    Thanks for the reply.. Let me articulate my requirement in a better way. I have identified an object ,earlier with a identifiable property that defines the current object state {say form's intial state when the menu is clicked }... I have saved the object as js variable..

              Now 'current form state' gets changed and new form with 'intial state' is opened by a another menu click . on refreshing the name mapping tree , alias mapping is refering to new form with initial state property, which is expected... But the old form object which i had in js variable is lost and its now refering to new form.



    Looks like alias.mapping is refering its own reference, but not the reference of the object its been mapped.. Is there any way to get hold of previous form instance as well.



    Thanks in advance
  • softwarevikram's avatar
    softwarevikram
    Occasional Contributor
    Srinivasan,



    Hope the object/variable refers to single "namemap/aliases" all the time irrespective of number of instances/variables/object you create for all of those which you assign different state of the application component that you deal. since all variables refer to the same/single namemap and whenver you refresh the objectmap, the latest state of the application component will be reflected to all the variables those holds the reference of that namemap. Instead of trying to assingn & retain the different state to different varaibles/object, you can get the state of the object(application component) during run-time which means that you should retrive the dynamically changing property of the namemap & verify with a condition of what you look for, when it matches, then do the task what you intended to do for that component with that particular state. To find the right component possessing the required/specific state/property loop through the available similar components how much ever is currently running. The core idea/functionality of TestComplete is that it looks for the "process" running in machine to identify the root of each namemap we do.
  • I think Checkpoints could help you out a lot. There are Property Checkpoints which let you check for different properties available for an object or child object. This may be the simplest to use.

    Then there are Region Checkpoints where you can capture an image, mask parts of it, compare the stored image with the newer image from playback etc. http://support.smartbear.com/viewarticle/57039/



    Since it sounds like you are needing the comparison more using a property checkpoint or region checkpoint may be the simplest to either script or keyword.

    If you use Keyword tests, you would get the object up to the point just before it changes, set the initial checkpoint, perform your next action which would change the form, then set the follow up checkpoint, then setup if statements after the initial checkpoint with the checkpoint as part of the requirements, have it perform the action, set another if statement with the follow up checkpoint as the requirement, then your next actions. 



    With script tests, I would functionalize the checkpoints have it return true or false, setup the initial checkpoint, setup an if statement with the checkpiont referencing the initial checkpoint, perform an action on true, exit program or loop on false, setup the follow up checkpoint, and repeat above.



    Hope this helps.

  • srini_g_vasan's avatar
    srini_g_vasan
    Occasional Contributor
    Thanks Jeremy and Vikram for the suggestions..



    Check points will help me only for state changes with in a single object. But In my case there are two form objects opened by sequential menu clicks ..



    First menu click --> opens the form--> its in intial state --> mapped to alias-->user actions to change the state --->storing the object reference to js variable.



    Second menu click --> opens the form--> its in intial state --> refreshing the namemapping(as mapping still refers to previous form)-->mapped to name mapping. 



    js variable in which i had old form instance is now referring to new form... Both the js variable and alais is now referring to second form... I do not have reference to first form...



    How can i work on this scenario



    ............................................................................................................................................

    ....................................................................................................