Search
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Articles Author
Wed, 22-Oct-2014 Authors
All Time Authors
Sourav.Kayal
39750
Sheonarayan
38050
Niladri.Biswas
33350

Latest members | More ...


(Statistics delayed by 5 minutes)
Ads
 Article

Object Identification Mechanism in Coded UI test

Dynamicruchi
Posted by under Visual Studio category on for Beginner level | Points: 250 | Views : 28785 red flag
If you found plagiarised (copied) or inappropriate content,
please let us know the original source along with your correct email id (to communicate) for further action.
Rating: 5 out of 5
1 vote(s)
In my last article on Coded UI Basic Walkthrough, we have seen the Record and Playback Mechanism of Coded UI. In this article I would like to discuss about the ‘Object Identification Mechanism of CodedUI’. How Coded UI identifies the objects present on the User Interface?

Each object has some search properties associated with it. Along with this, if the object’s Technology is Web then it also has Filter properties associated with it. Coded UI uses these properties to identify the objects at runtime.

Link of my last article - http://www.dotnetfunda.com/articles/article1241-coded-ui-test-basic-walkthrough-.aspx

 

Object’s Properties in CodedUI Test Editor

When some object is added using the Coded UI Test Builder and then generating the code using Generate Code button[right most in the below screenshot], Coded UI adds these objects in a file called UIMap(UIMap.uitest), Coded UI adds the exposed properties of the object as Search and Filter properties.

For more information on how to add objects using Coded UI, please refer to my previous article Coded UI Basic Walkthrough .

 

If you have Feature Pack 2 installed, you will be able to see the objects added in UIMap in CodedUI Test Editor. If you are a MSDN subscriber, you can install the Feature Pack 2 from http://msdn.microsoft.com/en-us/vstudio/ff655021

You can open the Test Editor by double clicking on the UIMap.uitest file present in the Solution Explorer, generated by Coded UI.

If you see the below screenshot, I am able to see the highlighted ‘UICloseDocumentTabButton’ in the UI Control Map.

 

 

Select the ‘Properties’ from context menu and you will see ‘Search Properties’ and ‘Filter Properties’ of the selected object in the Property Editor.

You can edit the object’s properties based on your requirements. E.g. if you know that object can be uniquely identified by its ‘Id’, you can remove all other Search and Filter properties. This will improve the performance of the CodedUI.

 

In case of Filter properties, the properties get checked one by one in the sequential order.

If object cannot be identified based on one filter property, then that property is ignored and Coded UI starts identifying the object based on the next filter property.

Object Identification Mechanism

During the Playback, Coded UI first searches for the object having all the specified search properties using ‘AND’ and then one by one it searches with filter properties using ‘OR’ and returns the resultant UI Object.

Search, then the first object satisfying the search would be returned.

Exceptions when  property is not found

In case of, Search Property not found:

For Web Technology:

 ‘UITestControlNotFoundException’ will be thrown

For MSAA/UIA Technology:

‘System.ArgumentException’ will be thrown

In case of, Filter property not found, it is just ignored.

 

Best Practices in Object Identification for Performance Improvement

 

·      Make the unique property as the ‘Search property’ of the object. And remove other Search and Filter properties.

·       If there are some properties in ‘Filter Property’ which can help in identifying the object uniquely, make that property as a ‘Search Property’.

·       Make prudent use of Search and Filter properties and Disable the Smart Match Identification. 

Conclusion

Coded UI uses Search and Filter properties of an object for identifying it during the Playback.

Prudent use of these properties can improve the Coded UI performance and make the test automation stable for future.

Page copy protected against web site content infringement by Copyscape
About the Author

Dynamicruchi

Full Name: Ruchi Srivastava
Member Level:
Member Status: Member
Member Since: 3/2/2011 1:00:59 AM
Country: India

http://www.dotnetfunda.com

Login to vote for this post.
Found interesting? Add this to:


Comments or Responses

Posted by: Chvrsri on: 3/9/2011 | Points: 25

Hi Ruchi Srivastava,

Nice article this helped me alot. !!!! Thanq so much

Posted by: Madhu.b.rokkam on: 3/9/2011 | Points: 25

nice one ruchi...

Posted by: Tripati_tutu on: 3/12/2011 | Points: 25

Good one...

Posted by: Mesh_2010 on: 3/15/2011 | Points: 25


hi Ruchi,

Good Article....



Posted by: Avinashpangotra on: 3/29/2011 | Points: 25

Hi Ruchi,

Really very informative one!!
Thanks a lot.
Also, I have one query:-
How can we get the properties of an object from the UI when we are automating through coded UI. For example, if I don't want to record and am automating test cases by coding, I will need the properties of an object to operate on it.IN QTP, we use the object Spy for the same, how do we do the same work here?

Posted by: Dynamicruchi on: 3/30/2011 | Points: 25

Hi Avinash,

Coded UI provides you a test builder(first image in this article) which contains a cross hair (third icon from left in test Builder). Move this cross hair to the object which you want to identify ,add this object and generate the code for this object. You will be able to work with this object's properties now. Use Coded UI Test Editor to see the properties of the objects.

Hope this helps. Please get back to me for any further clarifications.

Posted by: Avinashpangotra on: 3/30/2011 | Points: 25

Hi Dynamicruchi,
Thanks for the useful information. That was the information I was looking for.However, the cross hair is not usable at all compared to object spy. It talks a meticulous effort to drag the cross hair to the object whose properties u want to look for.However, through some research, I came to know that there are couple of other tools such as Inspect(Installed through Windows SDK for Windows 7 and .NET Framework 4), UI Spy(Installed through Windows SDK for Windows 7 and .NET Framework 3.5SP1), Snoop, UIA Verify which are comparatively more prolific.However, I haven't explored any of these tools yet.

Thanks,
Avinash

Posted by: Avinashpangotra on: 5/2/2011 | Points: 25

Hi All,

I want to see properties of the pane containing my link which I have to click through Automation.When I select the link with mouse and press Windows logo key + I, I will get all the properties of the link in the Coded UI Test Builder. Now If I expand the properties window to see the UI controlMap, I can see the Container Pane in the hierarchy above as one of the parents. If I select the pane, I can see some search properties for this pane along with a link "Show all the properties". Now if I click on the link "Show all the properties", the status bar says 'Unable to locate selected UI control'. This is because pane is a Java script pop up menu and when I click anywhere else (clicking "Show all the properties"), the menu disappears.If a select a parent(other than Container Pane) above in the hierarchy which is still visible, and click "Show all the properties", I can see that some more properties are listed by the Coded UI Test Builder for that parent.

Is there any way so that I can configure Coded UI test so that it captures/displays all the properties of all the parents of the object in the first go itself so that I don't have to click the "Show all the properties" link?

I really need to use some of the unique properties of the Container Pane and the ones listed there don't serve my purpose. So looking for a mechanism to get more properties.

Any thoughts/pointers in this direction are highly appreciated.



Thanks & Regards,

Avinash Kumar Sharma.

Posted by: Kalyan1403 on: 12/15/2012 | Points: 25

Im very new to coded ui automation. can u please suggest hw to prepare framework for one complete application

i have group of test cases hw to link and execute ata time
thanks in advance
Kalyan Santosh

Posted by: Sunilnanda89 on: 1/8/2013 | Points: 25

Hi,

Am new to Coded ui automation and have been using this tool for past two months to automate my web application.. I have a query to put forward.. I have successfully executed some test cases except few in which some challenges are yet to be solved. Recorded some actions including checking a checkbox but that doesnt seems to work while playback.. I got error which says "cannot find hidden control" .. Googled regarding this issue but dint find any solution for this.. It would be nice if i get a solution for this issue.


Thanks,
Nanda

Login to post response

Comment using Facebook(Author doesn't get notification)