示例#1
0
        public Locator(WhereFind where, LocatorProperty property)
        {
            var prop = property;

            _condition = prop.ToAndCondition();
            Where      = where;
            Properties = new List <LocatorProperty>()
            {
                prop
            };
        }
示例#2
0
        public Locator(WhereFind where, string name = null, string automationId = null, string className = null,
                       ControlType controlType      = default(ControlType))
        {
            var prop = new LocatorProperty
            {
                Name         = name,
                AutomationId = automationId,
                ClassName    = className,
                ControlType  = controlType
            };

            _condition = prop.ToAndCondition();
            Where      = where;
            Properties = new List <LocatorProperty>()
            {
                prop
            };
        }
        private static bool isMatch(this AutomationElement element, LocatorProperty property)
        {
            bool result = true;

            if (property.Name != null)
            {
                result = element.Current.Name == property.Name;
            }
            if (result && property.AutomationId != null)
            {
                result = element.Current.AutomationId == property.AutomationId;
            }
            if (result && property.ClassName != null)
            {
                result = element.Current.ClassName == property.ClassName;
            }
            if (result && property.ControlType != default(ControlType))
            {
                result = Equals(element.Current.ControlType, property.ControlType);
            }
            return(result);
        }