The Microsoft UI Automation is an Accessibility and Test Framework allowing programs to
control the GUI elements of native Windows applications. With QF-Test you can use the framework
in script nodes via the Jython module
de.qfs.UIAuto for Groovy,
QF-Test provides a package in the standard library with procedures for the most commonly needed interactions with GUI elements for direct and easy use of the API for test development. This chapter describes the standard library package.
You will find the procedures relevant for control of native Windows elements in
qfs.autowin. You can see several procedures marked as
deprecated. They have been replaced by normal nodes of the
win engine of QF-Test,
and the procedures in the
qfs.autowin package will not be further maintained.
However, you can continue using them as they are. If you encounter problems, for example with
scaled windows applications, it is advised to switch to the
||Figure 47.1: UI Automation procedures in the standard library|
When developing tests for native windows applications you generally need to perform the following steps:
|Starting the application|
The application to be tested may but does not necessarily have to be started via QF-Test.
When starting the application via QF-Test the client process started is listed in the QF-Test menu »Clients« and can also be stopped via QF-Test.
Please use the procedure
to check whether the application was started.
You will find an example for the start of an application in subsection 47.2.1.
|Listing the GUI elements of a window|
Before you can set up a test you need to get an overview of the GUI elements
of the application. You may either use the procedure
qfs.autowin.helpers.dumpComponents to print the
GUI elements to the QF-Test terminal or
qfs.autowin.helpers.dumpComponentsToFile to write them
to a file.
you to list the titles of all open windows of the desktop.
qfs.autowin.helpers.dumpComponents prints the name (Name),
the class (ClassName), the compontent type
(ControlType) and the Id (AutomationId) of the GUI elements, provided they
were implemented for the respective GUI element.
All the GUI elements visible on the Windows desktop are organized in a tree structure with the desktop as the root element. When calling the dump procedure you need to specify the window for which to list the GUI elements. Nesting of the components is represented via indentation.
Note The procedure dumpComponents() prints its output to the QF-Test terminal displayed in the botton part of the QF-Test window. The output is not displayed in the terminals which can be opened separately (client terminal and scripting terminals).
Please find an example in subsection 47.2.2.
|Information on single GUI elements|
allows you to print further information for single GUI elements,
including a list of the methods available for the element as well as
|Identifiers for GUI elements|
All procedures of the standard library package preforming actions on native
Windows applications need to determine the respective GUI element as the
first step and then perform the action in a second step. You find the
procedures in the package
Because all procedures use
to identify the GUI element, the parameters of this helper procedure are valid
for all the procedures performing an action on a GUI element.
The following parameters (and combinations) are valid (in the order of evaluation):
qfs.autowin.helpers.dumpComponentshows the name and the numeric value of the respective ControlType. In order to identify a GUI element via its ControlType you usually need to specify its name or its index (relative to the GUI elements in the window of that ControlType), too, except there is just the one GUI element of that ControlType in the window.
|Actions on GUI elements|
You will find procedures in the package
of the standard library for the most common actions. You are free to enhance the
package. We recommend to use a separate test-suite for the enhancement and not to
change the qfs.qft since we continuously update the standard library and ship
a new version with every QF-Test release.
qfs.autowin.keyeventsprovides procedures for replaying the keyboard events ENTER, TAB and DELETE. The procedure
qfs.autowin.keyevents.sendKeylets you replay any key like a single letter, a digit, a function key, etc, also combined with the modifiers SHIFT, CTRL and ALT. The event is replayed to the component with the focus in the given window.
pngformat. The procedure determines the screen coordinates of the element via
qfs.autowin.component.getGeometry. The actual comparison is done via the procedure getPositionOfImage() of the
qfs.autoscreenpackage of the standard library.
|Last update: 3/9/2021
Copyright © 1999-2021 Quality First Software GmbH