我没有用鼠标右键菜单尝试过任何东西。菜单是否显示在您的
panel.RightClick();
否则,您的面板不是上下文菜单的一部分吗?
您是否尝试过使用
panel.RightClick();
var propClick = panel.Get<MenuItems.PopupMenu>(SearchCriteria.ByText("Propeties"));
propClick.Click();
反而?
或者你可以试试 Menu 而不是 PopupMenu
var propClick = panel.Get<MenuItems.Menu>(SearchCriteria.ByText("Propeties"));
或者让白先为你决定,然后通过放置断点来读取类型
var propClick = panel.Get(SearchCriteria.ByText("Propeties"));
编辑:为此,以下方法可能有助于使用键盘命令选择上下文菜单。
除此之外,您可能想尝试使用键盘选择菜单。白色没有上下文菜单(鼠标右键菜单)的特殊键,但下面的方法可以帮助解决这个问题。
/// <summary>
/// Right mouse click simulation (SHIFT+F10)
/// </summary>
/// <param name="container">Container in whish the click should occur.</param>
private static void ShowContextMenu(this UIItemContainer container)
{
container.Keyboard.HoldKey(KeyboardInput.SpecialKeys.SHIFT);
container.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.F10);
container.Keyboard.LeaveKey(KeyboardInput.SpecialKeys.SHIFT);
}
这个选择上下文菜单
/// <summary>
/// Get the context menu (right mouse menu) of <paramref name="container"/> whre the current focus is.
/// </summary>
/// <param name="mainWindow">Main window of the application, because the context menu is always a child of the window.</param>
/// <param name="container">Container on which the right click shoul occur.</param>
/// <returns>Context menu</returns>
internal static PopUpMenu GetContextMenuOf(this Window mainWindow, UIItemContainer container)
{
using (CoreAppXmlConfiguration.Instance.ApplyTemporarySetting(c => c.PopupTimeout = 750))
{
container.ShowContextMenu();
return mainWindow.Popup;
}
}