Identifying MSAA Objects

Applies to TestLeft 4.80, last modified on April 13, 2021
Search Patterns

To search for objects identified via Microsoft Active Accessibility (MSAA), you use search patterns of the MSAAPattern type.

.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.MSAA namespace.

Java: The pattern belongs to the com.smartbear.testleft.testobjects package.

This pattern uses the following properties:

Property Type Description
Caption String The object’s accessibility name. For example, button text, window title, or static text that labels the object.
ControlIndex Integer Used for windowless objects. The object’s index (0-based) among sibling objects. Invisible objects (Visible = false) have ControlIndex of -1.
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
ObjectGroupIndex Integer The object’s index (1-based) among sibling objects with the same ObjectIdentifier.
ObjectIdentifier String The object’s accessibility name, or, if the object does not have one, its index (0-based) among sibling objects with the same ObjectType.
ObjectType String The object type that indicates its accessibility role. This is usually the object’s role without the ROLE_SYSTEM_ prefix. For example, the ListItem type corresponds to ROLE_SYSTEM_LISTITEM.
Visible Boolean Specifies whether the object is visible in the application. Objects that are out of screen bounds or overlapped by other objects are still considered visible.
WndClass String The window class name of the object. For example, SysTreeView32, MDIClient, #32770 (dialog box). This is a value returned by the GetClassName() Windows API function.

You can use any combination of these properties in your MSAA search patterns.



IWindow msoRibbon = Driver.Find<IProcess>(new ProcessPattern()
   ProcessName = "WINWORD"
}).Find<ITopLevelWindow>(new MSAAPattern()
   ObjectType = "Form",
   Caption = "* - Microsoft Word"
}).Find<IWindow>(new MSAAPattern()
   ObjectType = "ToolBar",
   Caption = "Ribbon"
}, 2);

Visual Basic .NET

Dim msoRibbon As IWindow = Driver.Find(Of IProcess)(New ProcessPattern() With {
   .ProcessName = "WINWORD"
}).Find(Of ITopLevelWindow)(New MSAAPattern() With {
   .ObjectType = "Form",
   .Caption = "* - Microsoft Word"
}).Find(Of IWindow)(New MSAAPattern() With {
   .ObjectType = "ToolBar",
   .Caption = "Ribbon"
}, 2)


Window msoRibbon = driver.find(Process.class, new ProcessPattern() {{
   ProcessName = "WINWORD";
}}).find(TopLevelWindow.class, new MSAAPattern() {{
   ObjectType = "Form";
   Caption = "* - Microsoft Word";
}}).find(Window.class, new MSAAPattern() {{
   ObjectType = "ToolBar";
   Caption = "Ribbon";
}}, 2);

Custom Properties

You can also specify custom properties by using the .add("propertyname", value) method of the pattern object. See Using Custom Properties in Search Patterns.

Object Types Identified via MSAA

MSAA allows TestLeft to identify child elements of certain objects. By default, TestLeft uses MSAA with the objects whose WndClass matches these wildcard patterns:

  • bosa_sdm_Microsoft Word *
  • _Ww*
  • MsoCommandBar*
  • OpusApp
  • Vfp*
  • XTPToolBar
  • XTPDockingPaneTabbedContainer
  • XTPTaskPanel
  • XTPReport
  • XTPPopupBar

To enable MSAA identification for other object types, use the Driver.Options.MSAA.AddWindow() method at the beginning of your test to specify additional object types:



Visual Basic .NET




Note: The changes are effective throughout the test run, until you start the next test run.

You can specify object types using the following syntaxes:


where WndClass is the object’s window class name, and WndCaption is the object’s caption (for windows – the title bar text).

In both values, you can use wildcards (* and ?) to match multiple object types based on some common pattern. The asterisk (*) matches a string of any length, including an empty string, the question mark (?) matches any single character or no character.


Object Type Description
NetUIHWND Objects with the window class NetUIHWND.
Vfp* Objects whose window class begins with Vfp.
XTPReport;@text=My Report Objects with the window class XTPReport and caption My Report.
*;@text=My Report Objects with the caption My Report and any window class.
*;@text=*Report Objects whose caption ends with Report.
* All objects. (Not recommended for performance reasons. Prefer specific object types.)
Customizing MSAA Object Types at Design Time

Currently, there is no direct way to customize MSAA object types at design time, but you can use this workaround:

  1. Create a dummy test with the code like the following one (this example is for MSTest):


    public void MSAATest()
      // Add your custom object types here
      Driver.Options.MSAA.AddWindow("object type 1");
      Driver.Options.MSAA.AddWindow("object type 2");


    Visual Basic .NET

    Public Sub MSAATest()
      ' Add your custom object types here
      Driver.Options.MSAA.AddWindow("object type 1")
      Driver.Options.MSAA.AddWindow("object type 2")

    End Sub


    public void MSAATest() throws Exception{
      // Add your custom object types here
      driver.getOptions().getMSAA().addWindow("object type 1");
      driver.getOptions().getMSAA().addWindow("object type 2");


  2. Run the test.

  3. Changes in options will be effective throughout the test run.

  4. After the test run is over, open UI Spy and examine the object tree (refresh the object tree, if needed).

  5. UI Spy will apply the new setting. You will be able to explore your custom objects and generate identification code for them.

Changes in options will remain effective until you start another test.

See Also

Understanding Object Identification

Highlight search results