index > Microsoft UI Automation > control ids

control ids


Hi

We have an automation software which detects Windows built-in control according to their ids.

We noticed that on Windows Vista build 5472, the ids are were totally changed comparing to the ids in Vista beta 2 and earlier.

Is it not correct to rely on the ids? Is there a better way to identify the type of a control (can't it's name change)?

Here is a code sample that we used to list the control ids:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Automation;
using System.Reflection;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
foreach (FieldInfo fi in typeof(ControlType).GetFields())
{
ControlType ct = fi.GetValue(new object()) as ControlType;
Console.WriteLine(string.Format("id: {0}\tname: {1}", ct.Id, fi.Name));
}
Console.Read();
}
}
}

rosebud75

In general, the automationId property is not intended for identifying specific elements across all platforms. It is more likely to be used, for example, by testing software that already knows the ID of an element on the platform it is testing, or for navigating within a subtree to a known element within that subtree. (Remember, automationIds are not unique on the desktop, only unique among siblings.)

If you are trying to locate a particular Windows element such as the Start button, you are probably better off looking for it by classname and name. However, there are never any guarantees that these will not change from version to version.




This posting is provided "AS IS" with no warranties, and confers no rights.
Peter Donnelly - MSFT

Hi Peter

I did not refer to a specifc element automation id, but rather to a "control id" - a unique number that identifies all controls of a specific type.
Have a look at the code sample above to see what I mean.

Thanks

rosebud75

My apologies for the brain cramp.

I'm curious to know why you are drilling down to the id of the ControlType. The static objects themselves (e.g. ControlType.Button) are what identify the types, and any searches or comparisons should work regardless of whether the underlying numerical id changes in future versions.




This posting is provided "AS IS" with no warranties, and confers no rights.
Peter Donnelly - MSFT
reply 4

You can use google to search for other answers

 

More Articles

• Custom control patterns
• UISpy missing from the February CTP
• Custom Property Conditions
• Issue: "Specified element is already the logical child of an...
• n00b vs. UI Automation
• C++ API Problems
• Preventing UI Automation access to an application
• Hang with InvokePattern - Invoke
• Test Automation for WPF apps
• UIAutomation support for downlevel OS
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Raising events for an application
• Automation Unit Testing
• Accessibilty
• Name property empty???
• Thread Synchronization between Automatio
• UI Automation on Web Browser(IE)
• Test Automation for WPF apps
• complexity of finding UI elements with T
• Textpattern giving exception by UIAutoma
• AutomationID and Templates
• Radio Button Automation in WPF
• C++ API Problems
• How to close multiple dialgs opened by o
• problems with vista 5365
• Automating WPF apps with VSTS

Hot Articles

• n00b vs. UI Automation
• MenuStrip is still missing from UISpy
• problems with vista 5365
• Textpattern giving exception by UIAutoma
• Extracting text from Third Party Controls
• Automate testing Website using C#
• UIA and WinForms 2.0
• Automation.AddAutomationEvent and WinForms
• UI Automation on Web Browser(IE)
• Automation element for PasswordBox
• Problem with TreeScope in Automation.Add
• How to close multiple dialgs opened by o
• AutomationFocusChangedEvent
• Attchment Contorl - UI Automation
• UI automation vs. Input classes (Keyboar

Recommend Articles

• control ids
• Raising events for an application
• Textpattern giving exception by UIAutoma
• Custom Property Conditions
• ClientSideProviders
• UI Automation for automated GUI testing?
• UIAutomation support for downlevel OS
• Attchment Contorl - UI Automation
• UISpy missing from the February CTP
• complexity of finding UI elements with T
• Documentation and ObjectFromPoint?
• Catching all events for an AutomationEle
• problems with vista 5365
• Welcome to Microsoft UI Automation Forum
• chevron command bar