Hello,
Could you please help me to figure out the cause of problem related to
UIAutomation.
The problem consists in impossibility to invoke (click) button in UI application (on some PC’s it works fine on some – not).
I was able to find that this problem is actual only for DevExpress-buttons.
When my utility is looking for a control (through Microsoft's UI Automation), in PC’s, where problem occurs, button is recognized as
ControlType.Pane (instead of ControlType.Button) and when we are trying to invoke such control,InvalidOperationException-is thrown (with Unsupported Pattern-message) asPane doesn’t support such kind of pattern.
In source code problem is in this part:
AutomationElement rootElement = AutomationElement.RootElement;
if (rootElement != null)
{
Condition condition = new PropertyCondition(AutomationElement.AutomationIdProperty, <main window name>);
AutomationElement appElement = rootElement.FindFirst(TreeScope.Children, condition);
if (appElement != null)
{
AutomationElement uiAutoElement = appElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, <button name to invoke>)); // in some PC's, control type is as expected - button, in some PC's - pane.
If I use Inspect.exe, to check control type, there is shown 'button' and it could be invoked from Inspect.