In the lessons for the
selenium. family of commands you learned how you can select webpage elements, using their XPaths. Guess what? Similar techniques can be applied to user interface elements such as input boxes, icons, buttons, menus and so on — by resorting to their WPaths in the
ui. family of commands.
WPath is an “address” of a Windows UI element. You can easily find it with the Windows Tree panel: select
Windows Tree from
View menu and you will see all available UI elements in a tree. If you are not sure what a cryptic element really is, right-click it and select Highlight from the context menu: the selected element will be highlighted in the GUI.
When you use any of the
ui. commands, just double-click a desired UI element in the Window Tree panel to insert its WPath into the command as a
wpath argument value.
Let’s use couple of the
ui. commands (but first, enable them by selecting the UI Addon in the Addons panel):
program mstsc ♥rdc = /ui[@name='Remote Desktop Connection'] waitfor.ui ‴♥rdc/ui[@id='5017']/ui[@name='Show Options ']‴ ui.click ‴♥rdc/ui[@id='5017']/ui[@name='Show Options ']‴ ui.settext ‴♥rdc/ui[@typeid='50003']/ui[@typeid='50004']‴ text test.domain.com delay 1 ui.settext ‴♥rdc/ui[@id='13064']‴ text admin
This script is a bit mysterious, so let’s explain it:
adminin the User name: input box.
Note: The names of window elements are system language dependent, so scripts with WPaths to these elements can be used only in the same language versions of Windows.
In the next lesson you will enhance the above script with some more actions.