Windows 组件对 UIA 的支持并不算很好:
In the Native Windows GUI features are missing: Lots of controls do not implement the patterns that they should implement. For example a SplitButton in a native Toolbar should implement the
Invoke
pattern to click the button and theExpandCollapse
pattern to open the drop-down menu. But theExpandCollapse
pattern is missing which makes it difficult to use SplitButtons. If you obtain a Toolbar SplitButton byIUIAutomation->ElementFromPoint()
and then ask for it's parent you will get a crippled element. And the Pager control cannot be automated at all.Also in WPF applications there are controls that are implemented buggy by Microsoft: For example if you have a Calendar control you see two buttons at the top to switch to the next/previous month. If you execute the
Invoke
pattern on these buttons you will get anUIA_E_NOTSUPPORTED
error. But this is not a bug on the client side of the framework, because for other buttons theInvoke
pattern works correctly. This is a bug in the WPF Automation server. And if you testIUIAutomationTextRange
with a WPF RichTextBox, you will find that several commands are not implemented:Select()
andScrollIntoView()
do simply nothing.or .NET Forms applications Microsoft did not make much effort to support them. The .NET Calendar control cannot be automated at all. The entire control is not even recognized as Calendar. It has the ControlType "Pane" with no child elements in it. The same applies to the DateTimePicker. And for complex controls like DataGrid and PropertyGrid the only implemented pattern is
LegacyIAccessible
which is a poor support. These controls should implement at least theTable
and theGrid
and theScrollItem
pattern.1
microsoft/EasyRepro: Automated UI testing API for Dynamics 365
System.Windows.Automation
的封装太旧了,性能很低,应该用 COM 调用 IUIAutomationElement
1:
- FlaUI: UI automation library for .Net
- FlaUI/UIAutomation-Interop: Interop wrappers for UIAutomationCore and UIAutomationClient (NuGet)
- White (deprecated)
- Inspect
- FlaUInspect: Inspect tool to inspect UIs from an automation perspective
- Accessibility Insights