private async Task <AutomationElement> LocateAutomationElementAsync(string elementName, bool recursive = false) { AutomationElement automationElement = null; var scope = (recursive ? TreeScope.Descendants : TreeScope.Children); var condition = new PropertyCondition(AutomationElement.NameProperty, elementName); await IntegrationHelper.WaitForResultAsync(() => { automationElement = AutomationElement.RootElement.FindFirst(scope, condition); return(automationElement != null); }, expectedResult : true).ConfigureAwait(continueOnCapturedContext: false); return(automationElement); }
private async Task <AutomationElement> FindAutomationElementAsync(string elementName, bool recursive = false) { AutomationElement element = null; var scope = recursive ? TreeScope.Descendants : TreeScope.Children; var condition = new PropertyCondition(AutomationElement.NameProperty, elementName); // TODO(Dustin): This is code is a bit terrifying. If anything goes wrong and the automation // element can't be found, it'll continue to spin until the heat death of the universe. await IntegrationHelper.WaitForResultAsync( () => (element = AutomationElement.RootElement.FindFirst(scope, condition)) != null, expectedResult : true) .ConfigureAwait(false); return(element); }
internal Task WaitForDteCommandAvailabilityAsync(string command) => IntegrationHelper.WaitForResultAsync(() => IntegrationHelper.RetryDteCall(() => Dte.Commands.Item(command).IsAvailable), expectedResult: true);
public Task WaitForReplPromptAsync() => IntegrationHelper.WaitForResultAsync(() => ReplText.EndsWith(ReplPromptText), expectedResult: true);
public static Task WaitForCommandAvailabilityAsync(this DTE dte, string command) => IntegrationHelper.WaitForResultAsync(() => IntegrationHelper.RetryRpcCall(() => dte.Commands.Item(command).IsAvailable), expectedResult: true);