public static AutomationElement TryWaitElement(this AutomationElement automationElement, TreeScope scope, Expression <Func <AutomationElement, bool> > condition, int?timeOut = null) { long start = PerfCounter.Ticks; var cond = ConditionBuilder.ToCondition(condition); var result = automationElement.FindFirst(scope, cond); if (result != null) { return(result); } while (true) { Thread.Sleep(DefaultSleep); result = automationElement.FindFirst(scope, cond); if (result != null) { return(result); } if (((PerfCounter.Ticks - start) / PerfCounter.FrequencyMilliseconds) > (timeOut ?? DefaultTimeout)) { return(null); } } }
public static AutomationElement Normalize(AutomationElement element) { if (element.Current.ControlType == ControlType.Window) { return(element); } TreeWalker walker = new TreeWalker(ConditionBuilder.ToCondition(a => a.Current.ControlType == ControlType.Window)); return(walker.Normalize(element)); }
public static Condition ToCondition(Expression <Func <AutomationElement, bool> > condition) { Expression <Func <AutomationElement, bool> > clean = (Expression <Func <AutomationElement, bool> >)ExpressionCleaner.Clean(condition); ConditionBuilder builder = new ConditionBuilder { parameter = clean.Parameters.Single() }; Expression expression = builder.Visit(clean.Body); return(AsCondition(expression)); }
public FilterOptionProxy LastFilter() { TreeWalker tw = new TreeWalker(ConditionBuilder.ToCondition(ae => ae.Current.ClassName == "FilterLine")); var filterLine = tw.GetLastChild(FilterBuilderControl); if (filterLine == null) { throw new ElementNotAvailableException("Last FilterLine not found"); } return(new FilterOptionProxy(filterLine, this)); }
public void SetValueString(string value) { var valueControl = new TreeWalker(ConditionBuilder.ToCondition(a => a.Current.ControlType == ControlType.Custom)).GetLastChild(Element); switch (valueControl.Current.ClassName) { case "ValueLine": new ValueLineProxy(valueControl, null).StringValue = value; break; case "EntityLine": new EntityLineProxy(valueControl, null).Autocomplete(value); break; default: throw new InvalidOperationException(); } }
public static Condition ToCondition(Expression<Func<AutomationElement, bool>> condition) { Expression<Func<AutomationElement, bool>> clean = (Expression<Func<AutomationElement, bool>>)ExpressionCleaner.Clean(condition); ConditionBuilder builder = new ConditionBuilder { parameter = clean.Parameters.Single() }; Expression expression = builder.Visit(clean.Body); return AsCondition(expression); }
public static AutomationElement TryElement(this AutomationElement element, TreeScope scope, Expression <Func <AutomationElement, bool> > condition) { var c = ConditionBuilder.ToCondition(condition); return(element.TryElementByCondition(scope, c)); }
public static List <AutomationElement> Elements(this AutomationElement parent, TreeScope scope, Expression <Func <AutomationElement, bool> > condition) { var c = ConditionBuilder.ToCondition(condition); return(parent.FindAll(scope, c).Cast <AutomationElement>().ToList()); }