What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 36420 |  Welcome, Guest!   Register  Login
Home > Articles > Visual Studio 2010/12 > Object Identification Mechanism in Coded UI test

Object Identification Mechanism in Coded UI test

1 vote(s)
Rating: 5 out of 5
Article posted by Dynamicruchi on 3/9/2011 | Views: 18072 | Category: Visual Studio 2010/12 | Level: Beginner | Points: 250 red flag


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.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:4 year(s)
Home page:http://www.dotnetfunda.com
Member since:Wednesday, March 02, 2011
Level:Starter
Status: [Member]
Biography:
 Responses
Posted by: Chvrsri | Posted on: 09 Mar 2011 06:41:42 AM | Points: 25

Hi Ruchi Srivastava,

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

Posted by: Madhu.b.rokkam | Posted on: 09 Mar 2011 02:47:13 PM | Points: 25

nice one ruchi...

Posted by: Tripati_tutu | Posted on: 12 Mar 2011 12:27:28 AM | Points: 25

Good one...

Posted by: Mesh_2010 | Posted on: 15 Mar 2011 04:56:26 AM | Points: 25


hi Ruchi,

Good Article....



Posted by: Avinashpangotra | Posted on: 29 Mar 2011 02:54:20 AM | 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 | Posted on: 30 Mar 2011 01:18:58 AM | 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 | Posted on: 30 Mar 2011 03:05:47 AM | 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 | Posted on: 02 May 2011 07:22:14 AM | 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 | Posted on: 15 Dec 2012 12:09:23 AM | 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 | Posted on: 08 Jan 2013 04:58:13 AM | 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

>> Write Response - Respond to this post and get points
Related Posts

Performance of an application is very important for a multi-user application. Performance is not only the speed of execution; it includes the load and concurrency aspects. Visual Studio is one of the tools used for Performance Test. Visual Studio Test edition or Visual Studio 2010 Ultimate provides the support for test automation.

In my previous articles, we have discussed about Coded UI basics and Object Identification Mechanism in Coded UI . In this article we will look into Data Driven approach in Coded UI. What dataSources it supports for providing the test data and how to use these datasources while working with CodedUI.

Providing the soutions for the common problems that occurs while performing Web Perfomance test in Visual Studio 2010

Visual Studio supports the performance testing of varies applications through different types of tests like Web Test, Load Test, etc. It also support the data generation for the performance testing. Data Generation Plan helps us to populate the database with bulk amount of test data.

There are lots of test automation frameworks to support the test automation of an application. Coded UI is the new testing model introduced in Visual Studio 2010. This will support the automation of Manual test steps etc. Coded UI is an automation framework which enables us to record a set of action, creates the code for the same and allows us to playback the recording for testing the application. It also gives the flexibility to write the custom code [hand-coded]. In this article we will discuss about how to create our first CodedUI test project.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 10:18:35 AM