Chapter 3 – Object String | UIA

Object String

Object String is a string which is used to identify an automation object based on its attributes and hierarchy in a particular application. Any tool can be used for object identification, ‘Microsoft Inspect’ is the recommended tool. (You can download it for free from Microsoft’s website. It also comes bundled with windows SDK)

The object string has the following format:

<Control Type>,Property::value>==><Control Type>,Property::value

Example: Consider the windows calculator as a sample application and Inspect as an object spying tool.

(Finding object string for  ‘%’ button  below)

Step 1:

inspect1

Control Type = Window  &  Name = Calculator

Object string here for the outer window will be

“Window,Name::Calculator”

Step 2:

inspect 2

Going down in hierarchy we again have :

Control Type = Window  &  Name = Calculator

So the  object string for the inside window will again be:

“Window,Name::Calculator”

Combining both the strings we have:

“Window,Name::Calculator>==>Window,Name::Calculator”

Step 3:

inspect 3

Control Type = Button  &  Name = Percent

The  object string for the inside window will be:

“Button,Name::Percent”

Combining all the strings we have:

“Window,Name::Calculator>==>Window,Name::Calculator>==>Button,Name::Percent”  

Now various actions can be performed on this button like click , doubleclick  etc..

 uia.Click “Window,Name::Calculator>==>Window,Name::Calculator,index::1,>==>Button,Name::Percent”  

Properties

  • Any unique property can be used for object identification.
  • Multiple properties can be use separated by comma ‘,’

        e.g. “Button,Name::Percent,AutomationId::percentButton”

Index

Index can be used in the cases where two elements have same properties.

e.g. “Button,Index::1”

Regular Expressions

Regular expressions can be used for objects with dynamic properties. It can be applied by adding ‘r|’ as a prefix to the property value.

e.g.  “Window,Name::r|Cal.*”

Generic Control Type

If the control type is not known then a generic control type can be used as below:

e.g. “Object,Name::Calculator” Here ‘Window’ is replaced by ‘Object’.

Smart algorithm  tries to find the element based on the other properties and ignores the control type. It can also be useful in the case when the actual application is not available.

 

 

Add a Comment

Your email address will not be published. Required fields are marked *