本文整理汇总了C#中System.Windows.Automation.AutomationElement.AddToSelection方法的典型用法代码示例。如果您正苦于以下问题:C# AutomationElement.AddToSelection方法的具体用法?C# AutomationElement.AddToSelection怎么用?C# AutomationElement.AddToSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Automation.AutomationElement
的用法示例。
在下文中一共展示了AutomationElement.AddToSelection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteQuery
public bool ExecuteQuery(AutomationElement querySet, AutomationElement queryNode)
{
string exportDir = Path.Combine(_exportDirectory, querySet.GetName());
if (!Directory.Exists(exportDir))
{
Directory.CreateDirectory(exportDir);
}
string fileName = Path.Combine(exportDir, queryNode.GetName() + ".html");
if (File.Exists(fileName))
{
File.Delete(fileName);
}
queryNode.AddToSelection();
var queryEditor = _mainWindow.FindChildByAutomationId("verticalSplit")
.FindChildByIndex(ControlType.Pane, 1)
.FindChildByAutomationId("tcQueries")
.FindChildByName(queryNode.GetName());
queryEditor.SetFocus();
var btnPin = queryEditor
.FindChildByAutomationId("QueryControl")
.FindChildByAutomationId("panTop")
.FindChildByAutomationId("btnPin");
//Mouse.Click(btnPin.GetClickablePoint().ToDrawingPoint());
var btnExecute = queryEditor
.FindChildByAutomationId("QueryControl")
.FindChildByAutomationId("panTop")
.FindChildByAutomationId("btnExecute");
btnExecute.Invoke();
// sleep just enough to start the query and show the status bar
Thread.Sleep(1000);
// wait for the status bar to say "Query sucessful"
var panBottom = queryEditor
.FindChildByAutomationId("QueryControl")
.FindChildByAutomationId("panMain")
.FindChildByAutomationId("splitContainer")
.FindChildByIndex(ControlType.Pane, 1)
.FindChildByAutomationId("panBottom");
while (true)
{
var statusStrip = queryEditor
.FindChildByAutomationId("QueryControl")
.FindChildByAutomationId("statusStrip");
if (statusStrip.FindChildByName("Query successful") !=null )
break;
Thread.Sleep(100);
}
// export to html
var mnuExport = panBottom
.FindChildByName("toolStrip1")
.FindChildByName("Export");
mnuExport.Invoke();
var mnuExportToHtml = mnuExport.FindChildByName("Export to HTML");
mnuExportToHtml.Invoke();
var dialog = _mainWindow.WaitForChild("Save Results", TimeSpan.FromSeconds(10));
var editFilename = dialog
.FindChildByIndex(ControlType.Pane, 0)
.FindChildByAutomationId("FileNameControlHost")
.FindChildByIndex(ControlType.Edit, 0);
var save = dialog.FindChildByName("Save");
editFilename.SetText(fileName);
save.Invoke();
_mainWindow.WaitForChildToDissapear("Save Results", TimeSpan.FromSeconds(10));
if (_baselineDirectory != null)
{
string baseline = Path.Combine(_baselineDirectory, querySet.GetName(), queryNode.GetName() + ".html");
string result = File.ReadAllText(fileName);
string expected = File.ReadAllText(baseline);
if (result != expected)
{
return false;
}
Console.Write("...baseline matches...");
}
return true;
}