简体   繁体   中英

UI Automation and Ribbon control

I do automation for WPF application using UIAutomation API. Everything went fine until I hit the Ribbon control. I have no trouble to see information about Ribbon and its children through the Inspect.exe, but inside the code I cannot obtain the information about those elements.

It other words, in this code aeElement is always null:

aeElement = aeForm.FindFirst(TreeScope.Children,
                  new PropertyCondition(AutomationElement.NameProperty, "XXX"));

I tried TreeScope.Descendants and TreeScope.Elements . I tried AutomationElement.ControlTypeProperty and AutomationElement.AutomationIdProperty . I tried TreeWalker – nothing worked.

Wondering if there is a solution for that issue? Thank you very much in advance.

EDIT: There is no answer at http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/home?forum=windowsaccessibilityandautomation either.

your worst case scenario is the root, correct? then try the following solution:

a. search from the root and then go deeper into the window, context, and so goes on

b. if a didn't work, then it must be your spelling. the name is case sensitive.

c. why aren't you using AutomationID? it was created for that use!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM