5.0+48.13
Windows Control API

The elments of native Windows applications are represented during a test by Java objects of the class WinControl. This class provides several public methods, e.g. to develop custom resolvers.

48.13.1
The WinControl class

Following is a list of the methods of the WinControl class in alphabetical order.

 
 
WinControl getAncestorByUiaType(String typeName)

Get the control ancestor which has the given UIAutomation type name.

Parameters
typeName The type name.
Returns The ancestor or null.
 
WinControl getChild(int index)

Get the control's child with the given index.

Parameters
index The index.
Returns The child.
Throws
IllegalArgumentException If index is negative or exceeds the number of child nodes.
 
int getChildCount()

Get number of children of the control.

Returns The child count.
 
WinControl[] getChildren()

Get the children of the control.

Returns An array with the children.
 
WinControl[] getChildrenByUiaClassName(String className)

Get all children of the control which have the given UIAutomation class name.

Parameters
className The class name.
Returns An array with the children.
 
WinControl[] getChildrenByUiaType(String typeName)

Get all children of the control which have the given UIAutomation type name.

Parameters
typeName The type name.
Returns An array with the children.
 
WinControl[] getElementsByClassName(String className)

Get all descendants of the control which match the given class name.

Parameters
className The class name to be matched.
Returns An array of WinControl objects, which have the current object as ancestor and match the given class name.
 
WinControl[] getElementsByClassName(String[] classNames)

Get all descendants of the control which match any of the given class names.

Parameters
classNames The class names to be matched.
Returns An array of WinControl objects, which have the current object as ancestor and match any of the given class names.
 
WinControl[] getElementsByClassName(String[] classNames, String[] stopClassNames)

Get all descendants of the WinControl matching any of the given class names, but skips all controls (and their decendants) matching the given stop class names.

Parameters
classNames The class names to be matched.
stopClassNames The stop class names.
Returns An array with the matching descendants.
 
String[] getGenericClassNames()

Get the generic class names of the control.

ReturnsAn array of Strings with the generic class names of the control.
 
int getHwnd()

Get the native window handle.

Returns The native window handle.
 
int[] getLocation()

Get the (physical) location of the element within its parent.

Returns An array with the X and Y coordinates.
 
int[] getLocationOnScreen()

Get the (physical) location of the element on the screen.

Returns An array with X, Y, width and height.
 
WinControl getNextSibling()

Get the control's next sibling.

Returns The next sibling or null.
 
String getPatterns()

Get all patterns in a string separated by whitespace. Prefer using hasPattern() for not to bother with the exact format of the return string.

Returns A string with the patterns of the element.
 
int[] getSize()

Get the (physical) size of the element.

Returns An array with the width and the height.
 
String getTextOrValue()

Get a value for an element, most of the time from the Value or Text pattern, if any. A value may also be retrieved from Text children or in special cases from the Automation Name.

Returns A value or null.
 
WinControl getTopAncestor()

Get the top-level ancestor of the control.

Returns The top-level ancestor or null.
 
String getUiaClassName()

Get the class name for the WinControl. This is the UIAutomation class name extended by a framework specific prefix to avoid confusion with QF-Test's generic class names.

ReturnsA String with the class name of the control.
 
AutomationBase getUiaControl()

Create an AutomationBase control for the WinControl, compatible with the uiauto script module (chapter 46).

Returns The AutomationBase object.
 
String getUiaDescription()

Get the UI Automation description of the control. If there is no full description, the accessibility description is returned as fallback.

Returns The description, if any or an empty string.
 
String getUiaHelp()

Get the UI Automation help text of the control.

Returns The help text, if any or an empty string.
 
String getUiaId()

Get the UI Automation identifier of the control.

Returns The ID, if any or null.
 
String getUiaName()

Get the UI Automation name of the control.

Returns The name, if any or null.
 
String getUiaType()

Get the type for the WinControl. This is the UIAutomation type name extended by a prefix Uia. to avoid confusion with QF-Test's generic class names.

ReturnsA String with the type of the control.
 
boolean hasPattern(String pattern)

Check whether the underlying Automation Element supports the given pattern.

Parameters
pattern The pattern name, e.g, "Invoke", "ExpandCollapse", etc.
Returns true if the pattern is supported by the element, false otherwise.
 
boolean isMatchingClass(String className)

Check whether the control matches a given class name.

Parameters
className The class name to be checked.
Returns true if the control matches the given class name, false otherwise.
 
boolean isMatchingClass(String[] classNames)

Checks if any of the given classNames is part of the WinControl's class names list.

Parameters
classNames The class names to be checked.
Returns true if the control matches one of the given class names, false otherwise.
 
boolean isShowing()

Get the visibility of an element.

Returns true, when the control is considered to be visible on the screen, false otherwise.