Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

Click menu item using .NET UI Automation

$
0
0

Hello,

I am working on a Automation project using .NET UI Automation APIs. 

I want to click a menu item on a Window, say w.

The only information that I have is handle of w. Now, I have to expand a Menu and select a menu item of it.

As per my understanding, I cam expand main menu [For example, File menu] by its name using Automation element FindFirst Menthod like below:

AutomationElement menu= winElement.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.NameProperty,"File"));

ExpandCollapsePattern p = menu.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
p.Expand();

Here, winElement is targeted window. Now, I am trying to find menu item "Reload" as below:

AutomationElement submenu = menu.FindFirst(TreeScope.Element, new PropertyCondition(AutomationElement.NameProperty, "Reload"));

But it is always returning null.  I also tried LocalizedControlTypeProperty of AutomationElement, but no luck.

Can you please tell me the better way to click a menu item with only information of window handle?

Thank you in advance!

Navanth


Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>