Forum Discussion

gdave's avatar
gdave
Regular Contributor
7 years ago
Solved

Object Alias Issue

Hi all

 

I am facing the below issue everytime I try and execute my test.

 

The problem here is when I initially use ObjectSpy to map the object, I get a mapped name eg: ListBox21 but after executing the test I get 'Object not found error'. After the failure, when I spy the same Object again it has now a different mapped name eg:ListBox15. I am not sure why the mapped name is changing after every run causing my test to fail. Any guesses?

 

 

Regards

G

  • Pretty much what I suspected: That the property(ies) of the object that you're using for identification are changing dynamically each time the application or test is run.  The solution is to find a property or set of properties that will uniquely identify the object so that, no matter what, it will always find the right one.

     

    Looking at the properties you've supplied, my suggestion would be to not use the Name property for mapping.  Instead, I'd use a combination of two or three properties:

     

    ObjectType = List

    ObjectIdentifier = ListBox

    wItemList = <the full list>

     

    Now, you COULD get away, I think, with just the first two assuming that the same screen doesn't have more than one list box on it.  If it only has the one, ObjectType and ObjectIdentifier should be sufficient.  If it has more than one list box, the other unique identifying factor is the list of items contained.

     

    Change your mapping to this and you'll have a more stable mapping for your list box

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What it sounds like is that the item in question has a variable property value in use within your mapping and you have the item mapped multiple times.  It would be helpful to see the mapping properties and values being used for ListBox21 and ListBox15. As well as the property list in ObjectSpy for the object in question.

     

    Essentially, it comes down to needing to correct your mapping so that the object in question is mapped accurately in such a way that it stays "static" in your identification.  You may need to edit your namemapping and delete and "duplicate" mappings where the same object may be mapped several times once you get the actual mapping sorted out.

    • gdave's avatar
      gdave
      Regular Contributor

      After some investigation I just realised that its not Alias but the actual object itself which is changing its Name. For example:

       

      An Alias 'ListBox' was mapped to UIAObject(ListBox32) and this UIAObject has 19 child items. I execute my test with this mapping and it passed. However next day when I try to re-run the same test it says 'Unable to find the object that matches the 'ListBox' item. If you looked at the attached screenshot from Name Mapping Editor (screenshot 1), the ObjectIdentifier (Alias 'ListBox') is mapped to UIAObject(ListBox32) which has got 19 child items, however, when I again spy on actual on screen object (screenshot2) the MappedName property is blank (screenshot3) and the actual Object name has been changed to ListBox from UIAObject(ListBox32) . This change in behaviour is causing my tests to fail.

       

      Now the surprising bit here is that if I remap the new object name (ListBox) the test passes however if I again try to re-run the same test, it fails AND the object name has again changed to UIAObject(ListBox32) from ListBox (screenshot 4) causing the same error as above. So my question here is that why is the original object name in question changing its name sporadically and how can I make it stable so that it doesn't change ?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Pretty much what I suspected: That the property(ies) of the object that you're using for identification are changing dynamically each time the application or test is run.  The solution is to find a property or set of properties that will uniquely identify the object so that, no matter what, it will always find the right one.

         

        Looking at the properties you've supplied, my suggestion would be to not use the Name property for mapping.  Instead, I'd use a combination of two or three properties:

         

        ObjectType = List

        ObjectIdentifier = ListBox

        wItemList = <the full list>

         

        Now, you COULD get away, I think, with just the first two assuming that the same screen doesn't have more than one list box on it.  If it only has the one, ObjectType and ObjectIdentifier should be sufficient.  If it has more than one list box, the other unique identifying factor is the list of items contained.

         

        Change your mapping to this and you'll have a more stable mapping for your list box