cancel
Showing results for 
Search instead for 
Did you mean: 

How to use AutomationID in nameMapping to identify WPF objects uniquely

Highlighted
New Contributor

How to use AutomationID in nameMapping to identify WPF objects uniquely

Hi,

I am automating an WPF application whose control names may change during software development. So I am planning to use Automation IDs to identify objects uniquely. Is there any way to do this using TestComplete?

The TestComplete version I am using is 12.30.

 

I have made below setup:
1. Go to File->Current Project Properties->Open Applications->UI Automation 
 2. Enable the asterisk (*) item in the list of accepted windows. 
 3. Go to File->Current Project Properties->Open Applications->General 
 4. Move the NativeUIAObject to the top of the priority list. 
5. Record one action in keyword test, then the default properties of the nameMapping contains: FrameworkID; ClassName; LocalizedControlType; ObjectIdentifier.
And the value of ObjectIdentifier is the same with the value of the object in NameMapping hierarchy.
And I have found out that the "AutomationID" is a different property compared with "ObjectIdentifier".
 
 
Thanks in advance!
 
 
 
Thanks,
Xiujuan

 

 

 

 

Thanks,

Xiujuan

 

 

5 REPLIES 5
Highlighted
Community Hero

Re: How to use AutomationID in nameMapping to identify WPF objects uniquely

Is the AutomationID a property only available via UI automation? I dont recall but I don't think so. Even so, you can us any properties in NameMapping. You don't need to keep what was automated.

With your compoelnent on screen, right click on the item in NameMapping and select aedit. You can add or modify any properties you wish.

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
New Contributor

Re: How to use AutomationID in nameMapping to identify WPF objects uniquely

Thanks for your reply first, I got it.

 

Another question I want to ask is how to add AutomationID  as the default property? From TestComplete's website, it says that for the object "ObjectIdentifier"

 

"The value of one of the following native properties of the object (ordered by priority):

please refer to; https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/uia/objectidentifier-...

 

I want to use AutomationID as the default value of the "ObjectIdentifier", so that I don't need to add the "AutomationID" manually for each object each time, that would be saving time greatly.

 

Thanks,

Xiujuan 

Highlighted
Community Hero

Re: How to use AutomationID in nameMapping to identify WPF objects uniquely

I don't believe that there is a way to change that hierarchy or priority.  If your UI Automation object has a "Name" property, that is what is going to be used.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Hero

Re: How to use AutomationID in nameMapping to identify WPF objects uniquely

Hi Xiujuan,

 

Check if NameMapping Template can help in your case: http://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/templ...

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
New Contributor

Re: How to use AutomationID in nameMapping to identify WPF objects uniquely

Hi Alex,

Thanks~

 

Yes I tried the "template" method but for me it doesn't work as described.

My goal is: add "AutomationID" as default identification property for every object/controls.

 

The first issue is: it requires to fill in the "Category" field myself. I tried to enter in ".NET Objects" and "WPF Controls" as two templates but I am not sure whether the wording is correct. is there any way easier? or is there any category which covers all the controls?

 

 Capture.PNGCapture2.PNG

 

The Second issue is: after I set the template as below: add two templates for two specific objects, and then record a new keyword test, then only the two objects has the AutomationID as their nameMapping property, the other objects still follows the nameMapping property as they were. it's even slower than I manually add automationID to the specific two objects, and my goal is to add AutomationID to all objects.

 

The third issue is: from http://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/dialo...

it says:

"To modify the value of a base property, enter the new values in the property’s Criteria cell. You can use regular expressions to specify variable parts of the property value. For example, to associate a template with an object that has a specific property regardless of the property value, specify .* in the property’s Criteria cell (this regular expression matches any string)."

 

So I change the value to be "*" for the two specific objects which were used to setup two templates, then record the keyword test, this time NO object has the "automationID" in their nameMapping, neither does the two specific object.

 

I am so confused, do you have any suggestions on that? I really don't want to add "AutomationID" manually for each object...

 

 

 

thanks,

Xiujuan