Exemple #1
0
        public static UIObject GetTopLevelUIObject(UIObject topWindow)
        {
            if (topWindow == null)
            {
                throw new ArgumentNullException(paramName: nameof(topWindow));
            }
            Log.Out(msg: "GetTopLevelUIObject: object");
            UIObject element = null;

            if ((ControlType)topWindow.GetProperty(property: UIProperty.Get(name: "ControlType")) != ControlType.Window)
            {
                throw new InvalidOperationException(message: "topWindow didn't find a window (ControlType==Window) after app activation completed.");
            }
            if (topWindow.ClassName.Equals(value: "Windows.UI.Core.CoreWindow", comparisonType: StringComparison.OrdinalIgnoreCase))
            {
                element = topWindow;
            }
            else
            {
                uint num;
                for (num = 0U; num < 10U && !topWindow.Children.TryFind(condition: UICondition.CreateFromClassName(className: "Windows.UI.Core.CoreWindow").AndWith(newCondition: UICondition.CreateFromName(name: topWindow.Name)), element: out element); ++num)
                {
                    Thread.Sleep(millisecondsTimeout: 100);
                }
                if (element == null)
                {
                    throw new UIObjectNotFoundException(message: string.Format(format: "Unable to find {0} in {1}", arg0: "Windows.UI.Core.CoreWindow", arg1: topWindow));
                }
                Log.Out(msg: "Found {0} in {1} tries", (object)"Windows.UI.Core.CoreWindow", (object)num);
            }

            return(element);
        }
        static UIProperty Create(
            string name,
            AutomationProperty property,
            Type allowedType)
        {
            UIProperty uiProperty;

            if (!_propertyTable.TryGetValue(key: name, value: out uiProperty))
            {
                uiProperty = new UIProperty(name: name, property: property, allowedType: allowedType);
                _propertyTable.Add(key: name, value: uiProperty);
            }

            return(uiProperty);
        }
 public static bool IsGlobalizableProperty(UIProperty property)
 {
     return(property != null?IsGlobalizableProperty(property : property.Property) : throw new ArgumentNullException(paramName: nameof(property)));
 }
 public static UICondition Create(UIProperty property, object value)
 {
     Validate.ArgumentNotNull(parameter: property, parameterName: nameof(property));
     return(new UICondition(condition: new GlobalizablePropertyCondition(property: property.Property, value: value)));
 }
Exemple #5
0
 public object GetCachedProperty(UIProperty property)
 {
     Validate.ArgumentNotNull(parameter: property, parameterName: nameof(property));
     return(WrapValue(value: AutomationElement.GetCachedPropertyValue(property: property.Property, ignoreDefaultValue: false)));
 }
        static void BuildDescription(Condition condition, StringBuilder stringBuilder)
        {
            if (condition == Condition.TrueCondition)
            {
                stringBuilder.Append(value: "True");
            }
            else if (condition == Condition.FalseCondition)
            {
                stringBuilder.Append(value: "False");
            }
            else
            {
                switch (condition)
                {
                case PropertyCondition propertyCondition:
                    stringBuilder.Append(value: UIProperty.Get(property: propertyCondition.Property));
                    stringBuilder.Append(value: " = ");
                    stringBuilder.Append(value: propertyCondition.Value);
                    break;

                case AndCondition andCondition:
                    var conditions1 = andCondition.GetConditions();
                    stringBuilder.Append(value: "(");
                    for (var index = 0; index < conditions1.Length; ++index)
                    {
                        BuildDescription(condition: conditions1[index], stringBuilder: stringBuilder);
                        if (index == conditions1.Length - 1)
                        {
                            stringBuilder.Append(value: ")");
                        }
                        else
                        {
                            stringBuilder.Append(value: " and ");
                        }
                    }

                    break;

                case OrCondition orCondition:
                    var conditions2 = orCondition.GetConditions();
                    stringBuilder.Append(value: "(");
                    for (var index = 0; index < conditions2.Length; ++index)
                    {
                        BuildDescription(condition: conditions2[index], stringBuilder: stringBuilder);
                        if (index == conditions2.Length - 1)
                        {
                            stringBuilder.Append(value: ")");
                        }
                        else
                        {
                            stringBuilder.Append(value: " or ");
                        }
                    }

                    break;

                case NotCondition notCondition:
                    stringBuilder.Append(value: "Not ");
                    BuildDescription(condition: notCondition.Condition, stringBuilder: stringBuilder);
                    break;

                default:
                    stringBuilder.Append(value: "[Unknown UICondition]");
                    break;
                }
            }
        }
 public UICollection <I> FindMultiple(UIProperty uiProperty, object value)
 {
     return(FindMultiple(condition: UICondition.Create(property: uiProperty, value: value)));
 }
 public I Find(UIProperty uiProperty, object value)
 {
     return(Find(condition: UICondition.Create(property: uiProperty, value: value)));
 }
 public bool TryFind(UIProperty uiProperty, object value, out I element)
 {
     return(TryFind(condition: UICondition.Create(property: uiProperty, value: value), element: out element));
 }
 public bool Contains(UIProperty uiProperty, object value)
 {
     return(Contains(condition: UICondition.Create(property: uiProperty, value: value)));
 }
 public void AddFilter(UIProperty uiProperty, object value)
 {
     Navigator.AddFilter(condition: UICondition.Create(property: uiProperty, value: value));
 }