This project is read-only.

Using White/UIAutomation How to get a right-click context menu

Mar 17, 2011 at 5:38 PM

When using UIAutomation I can't seem to be able to get a reference to the context menu that is shown when a right click is command is executed.
The following example shows a case where I opened up a new window with a (windows explorer inside it),got its correct reference from the available DesktopWindows (note that I can move it ok) and triggered the context menu via a right-click. 

var windowName = "This is a WinForms window: {0}".format(3.randomLetters());
var topPanel =<Panel>(windowName,600,200 );
var webBrowser = topPanel.add_WebBrowser_Control();"".o2Temp2Dir());
var guiAutomation = new API_GuiAutomation();
var window = guiAutomation.desktopWindow(windowName);

return window.Popup;


I tried to use the window.Popup variable to get the popup but that was null (not that the window object is of type White.Core.UIItems.WindowItems.WinFormWindow

Mar 17, 2011 at 11:41 PM

I found a way to do this:

		public static PopUpMenu getContextMenu(this API_GuiAutomation guiAutomation)    	


				var emptyWindow = guiAutomation.desktopWindow("");
				return emptyWindow.Popup;
			return null;


which can then be consumed like this:

		var contextMenu =  guiAutomation.getContextMenu();"Git Clone...").click();