UI automation for Context menu after right click.

Apr 18, 2015 at 2:51 PM
Edited Apr 18, 2015 at 3:03 PM
Hello everyone,

I've been looking at how I could access the items from the Context menu, however, my search has not been successful so far.
I found that the ContextMenu appeares as a child of Desktop, and this is what MSDN also confirms. I am doing automation for console application.
However, when I debug to see the children of the Desktop, or try accessing my Context menu from my root - it's saying that it's not there.
Moreover, UISpy/Inspect is telling me that the ProcessID is relevant to my application. So where is the muggle up with the parent?

Below is code sample that I am using

//Launched application here
Application Console2 = Application.Launch(@"C:\Program Files (x86)\ABC.exe");
Thread.Sleep(3000);

// got context on main window of application
Window MainWindow = Console2.GetWindow("ABC", White.Core.Factory.InitializeOption.NoCache);

// In the console there is tree and got focus on that well
Tree GetTree = MainWindow.Get<Tree>(SearchCriteria.ByAutomationId("9999"));
TreeNode computertree = MainWindow.Get<TreeNode>(SearchCriteria.ByText("Machines"));

// Searched treee node as Groups and right click on that control
TreeNode DMG = DSMainWindow.Get<TreeNode>(SearchCriteria.ByText("Groups"));
DMG.Click();
DMG.RightClick();

After right click TreeNode I got pop up menu and I wanted to click one of the option(Menu Item) available on that. However in Inspect tool Pop up menu shows as Context and its child of Desktop.
I am not able to focus on Context Menu and click on the option (Menu Item) available on this?
Could anyone guide me on this how to click on Menu Items available on Context Menu?

Thanks in advance!