The document discusses Powershell UI Automation, which allows automated testing of graphical user interfaces using Powershell scripts. It provides an overview of GUI testing tools before selecting Powershell UI Automation as the winner due to its advantages like being free, open-source, and using the known Powershell framework. It then covers how to install and use the tool via Powershell cmdlets to perform actions like getting windows and controls, invoking clicks and edits, and taking screenshots. Examples are provided and tips discussed for effective use.
11. UI Automation
●
API to access/manipulate GUI elements
●
Successor to MSAA
●
Released by Microsoft in 2005
●
Native part since Vista/Server 2008
●
Separate packages down to Windows XP
●
Managed API since .NET 3.0
●
Used also for assistive technologies
12. Powershell UI Automation
●
Powershell module using UIA API
●
Wide range of supported UI operations
●
●
Supports Win32, Windows Forms, WPF,
Metro UI, Java SWT, PowerBuilder, Delphi
Requires Powershell 2.0+ and .NET 3.5+
14. Available actions
●
Getting window (Get-UIAWindow)
●
Getting components (Get-UIAButton, Get-UIAEdit,)
●
Invoking actions (Invoke-UIACheckBoxToggle)
●
Setting values (Set-UIAEditText)
●
Getting values (Get-UIAEditText)
●
Browsing menu (Get-UIAMenuItem, Invoke-UIAMenuItem)
●
Checking state (Test-UIAControl)
●
Screenshots (Save-UIAScreenshot)
●
Get component attributes (Read-UIAControlName)
●
Waiting for element state (Wait-UIAButtonEnabled)
●
Start-UIARecorder
●
…....
15. Getting Window
Get-UIAWindow
●
Process Name (-ProcessName, -pn)
●
Process Id (-ProcessId, -pid)
●
By Title (-Name)
●
From process
●
Wildcards can be used
●
Returns AutomationElement object
●
Get-UIAActiveWindow
●
What if more processes are started?
16. Getting a Control
Get-UIAControl
●
Various Cmdlets to obtain all possible GUI elements
Get-UIAButton, Get-UIAEdit, Get-UIARadioButton, ...
●
Returns AutomationElement object
●
Many aliases
Get-UIAEdit = Get-UIATextBox
●
Cmdlets wrap Get-UIAControl
●
Name (-Name, -n)
●
Automation Id (-AutomationId)
●
Wildcards can be used
●
Multiple objects can be selected ([x-y])
●
Popups are also processed
19. Passing Objects
●
Passing control object as parameter
$btn = Get-UIAButton -Name „Next“
Invoke-UIAButtonClick -InputObject $btn
●
Passing object through pipe
Get-UIAButton -Name „Next“ | Invoke-UIAButtonClick
●
No need to pass window
20. Global Settings
●
Global settings can be modified
Logging, Timeouts, Highlighting, Screenshots, Error handling, ...
●
Usage:
[UIAutomation.Preferences]::Key = $value
●
Cmdlet Show-UIAModuleSettings
●
Some settings can be overriden locally
Get-UIAButton -Timeout 20
23. Tips & Tricks
●
Tools
UIVerify, UISpy, Spy++
●
Getting control nane
Get-UIAWindow | Get-UIAButton | Read-UIAControlName
Get-UIAWindow | Get-UIAControl | Read-UIAControlName
●
Get cmdlets related to control
Get-Command -Module UIA* *Button*
24. Gotchas
●
Lack of documentation
●
Last update in February 2013
●
Still officially Beta
●
Loosing focus on window
●
Needs to set focus on element to perform action
●
User account limitations
●
Save screenshot on error by default
25. Do you want to know more?
●
http://msdn.microsoft.com (UIA API, .NET)
●
http://uiautomation.codeplex.com
●
http://softwaretestingusingpowershell.com