3

Basically i am working on UI automation testing of a windows based application using visual studio CODE UI, problem comes as and when the layout changes or some new control is added in the GUI,and the control ID of the controls change.As we can see from the screenshot that a typical hierarchy is recoreded by CODE UI builder which is :-

Main Window ->Window with Control Id property -> Actual control.

So here are my questions related to this heirarchy and control Ids?

1) How are these Control IDs generated?

a) I know there is some logic by which these control ID Nos are generated, depending on the depth of the control in the GUI,but i am not able to find out any consistent way of how they are generated , for example in images the two buttons connect and help seems to be in same level of GUI but still their control IDs are so different 1 and 5013.

b) Are these control IDs generated by coded UI builder used in Testing environment or there is some logic in product development side or that code itself by which they are generated

2)Is there a way to skip this middle layer of window with control ID and do the record and playback successfully.(As in my case we have access to logical name of all the controls which themselves are unique in nature ,and we are good to get rid of these control IDs)

3)Plus Can we have hybrid approach where we have two layers for almost all controls but three layers for some special cases where its not possible to work with logical name or label only and we explicitly require control IDs

4)Last but not least how much of the accessibily implementation of this type can be done in Testing Environment as per my knowledge most part of accessibilty of controls has to be done on the product development Environment by adding some properties in code itself which then can be retrived for testing using various tools like CODE UI in testing Environment. But for large scale products i dont think that is a good approach as it imposes extra burden on development side and it is like adding extra unnecessary code in product(needed for testing purposes only) which needs to be delivered to the customer.

Plz see images below as a reference for clarity on my questions.

1st Image shows Remote Desktop GUI

2nd shows Computer: control properties recorded by CODED UI

3rd shows Connect Button properties recorded by CODED UI

4th shows Help Button properties recorded by CODED UI

Remote Desktop Computer: Connect Button Help Button

1
  • 1
    This is sad, i had so much expectation with Stack ppl .. its ok if i dont get any answer but i expected some ..tries or suggestions at least Commented Mar 15, 2013 at 10:57

1 Answer 1

1

I am only starting with CodedUI now, but I did a lot of UI Automation using different products before and using the same technology (MSUIA etc.). So this should apply here as well.

Each control has several properties, like name and automationid to name the most important ones. If you are automating a UI that is your own (you code/build it yourself) you should always attempt to give a unique automationid to each control, that will make your life a lot easier when automating. Name often is a bad option, since it frequently changes when you have a different language version of a program.

Since in that case you do not have the source and cannot influence the values it reports, you have to work with what is given. Still, even though CodedUI recorder will choose any property it sees fit, you can change the search criteria yourself by changing the UIMap.uitest for each element found:

VS Edit Search Properties box

This probably will take some time getting used to.. especially for more complicated UIs where elements have similar properties, also for dynamic UIs, etc.

By the way, the products I was using earlier on directly were working with AutomationElements, and here you have the full power to select and do what you want - even though with a high maintenance and start cost. (Ok, so it is generally very time consuming - and will always be more time consuming than using any ready solution like VS Coded UI.)

One more easy solution also is to simply go by coordinates (relative to some known controls, like main window or a tab group), this also will work 99% of the time and bring you to your goal that much quicker.

Ok, answering your concrete questions

1) if that is what I think it is, they are generated at runtime and there really is no relying on them

2) When going lower level (like AutomationElement) you can search whole trees. Still, that will typically make the search rather slow as well - not much faster then if you get the whole tree yourself and traverse it

3) You can mix anything you want. Actually, you can even convert handles to AutomationElements to Controls (at least for most standard controls). So you could use any technology, like Win32 SDK, to traverse the tree. Actually, all GUI trees in all technologies are similar - though not the same. And few people coding seem to adhere to any standards.. at least that is my experience.

4) Using a variation of technologies, coordinates (actually, I even used screenshots) etc you can achieve almost everything. It takes a lot a lot of time though. Getting the basics right during development and taking feedback from UI test developers into account can greatly help speed up later testing. Simplest example: whether an application paints "all ok" on the screen or whether there is a control that can reach that has a name property that says "all ok" - second solution will be a lot better for the automation guy.

Also, for more complicated UIs, if you are in a corporate environment, have some money and want to spend a lot of time on UI tests anyway, I suggest a product like Ranorex, SilkRunner and the like. I worked with a Ranorex Eval for a few days and (after some getting used to it) could navigate UIs that very rather difficult to navigate myself beforehand.

Sign up to request clarification or add additional context in comments.

3 Comments

OK .. thanks for the reply .... since you have been working on MSUIA, etc, since long.. do you have any idea is there a pattern followed on how these control ids are generated.. all i have come to know is that when you design a window form it puts every control in a separate window and these window have these control IDs associated with it..when the control position changes relative to other ..like earlier some control was appearing at end but now it has been shifter to top then ..its windows control ID will change.
Also , you were saying about these unique automationids, is there a great amount of work associated with these at dev. side. if not we can atleast think of working towards that approach. One of my friend is working with selenium automation and there they have this concept on unique automationids, but their application is Java Based and mine is Window based technology ,how much will it be feasible to my application.
Sorry, I have no idea about by which scheme they are generated. As for your own IDs: they are easy to set in both WPF and WinForms (there being simple properties, even with VS-Designer-support). For MFC I cannot really remember.. I think the basic ones (AutomationId is a basic one) you can easily set as well, whereas for the advanced ones you need to implement .com interfaces.. but that you don't need (unless you want to set HelpText and the like - which are other automation properties).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.