本文整理汇总了C#中Microsoft.VisualStudioTools.VisualStudioApp.FindByAutomationId方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStudioApp.FindByAutomationId方法的具体用法?C# VisualStudioApp.FindByAutomationId怎么用?C# VisualStudioApp.FindByAutomationId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudioTools.VisualStudioApp
的用法示例。
在下文中一共展示了VisualStudioApp.FindByAutomationId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomCommandsAdded
public void CustomCommandsAdded() {
using (var app = new VisualStudioApp()) {
PythonProjectNode node;
EnvDTE.Project proj;
OpenProject(app, "Commands1.sln", out node, out proj);
AssertUtil.ContainsExactly(
node._customCommands.Select(cc => cc.DisplayLabel),
"Test Command 1",
"Test Command 2"
);
app.OpenSolutionExplorer().FindItem("Solution 'Commands1' (1 project)", "Commands1").Select();
var menuBar = app.FindByAutomationId("MenuBar").AsWrapper();
Assert.IsNotNull(menuBar, "Unable to find menu bar");
var projectMenu = menuBar.FindByName("Project").AsWrapper();
Assert.IsNotNull(projectMenu, "Unable to find Project menu");
projectMenu.Element.EnsureExpanded();
try {
foreach (var name in node._customCommands.Select(cc => cc.DisplayLabelWithoutAccessKeys)) {
Assert.IsNotNull(projectMenu.FindByName(name), name + " not found");
}
} finally {
try {
// Try really really hard to collapse and deselect the
// Project menu, since VS will keep it selected and it
// may not come back for some reason...
projectMenu.Element.Collapse();
Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);
Keyboard.PressAndRelease(System.Windows.Input.Key.Escape);
} catch {
// ...but don't try so hard that we fail if we can't
// simulate keypresses.
}
}
}
}