public void GetWindowSearchConditionsWhenProcessIdIsValid()
 {
     List<AutomationSearchCondition> conditions = new AutomationSearchConditionFactory().GetWindowSearchConditions(1);
     Assert.Equal(2, conditions.Count);
     Assert.IsType<AndCondition>(conditions[0].Condition);
     Assert.IsType<AndCondition>(conditions[1].Condition);
 }
 public void GetWindowSearchConditionsWhenProcessIdIsValidTest()
 {
     var conditions = new AutomationSearchConditionFactory().GetWindowSearchConditions(1);
     Assert.That(conditions, Has.Count.EqualTo(2));
     Assert.That(conditions[0].Condition, Is.TypeOf<AndCondition>());
     Assert.That(conditions[1].Condition, Is.TypeOf<AndCondition>());
 }
예제 #3
0
        public virtual AutomationElement FindWindow(string title, int processId)
        {
            List<AutomationSearchCondition> windowSearchConditions = new AutomationSearchConditionFactory().GetWindowSearchConditions(processId);
            foreach (var searchCondition in windowSearchConditions)
            {
                AutomationElement windowElement = Child(searchCondition.OfName(title));
                if (windowElement != null) return windowElement;
            }

            return Child(0,
                         new[]
                             {
                                 AutomationSearchCondition.GetWindowWithTitleBarSearchCondition(processId),
                                 AutomationSearchCondition.ByControlType(ControlType.TitleBar).OfName(title)
                             });
        }
예제 #4
0
        public virtual AutomationElement FindWindow(string title, int processId)
        {
            var windowSearchConditions = new AutomationSearchConditionFactory().GetWindowSearchConditions(processId);

            foreach (var searchCondition in windowSearchConditions)
            {
                var windowElement = Child(searchCondition.OfName(title));
                if (windowElement != null)
                {
                    return(windowElement);
                }
            }

            return(Child(0, new[]
            {
                AutomationSearchCondition.GetWindowWithTitleBarSearchCondition(processId),
                AutomationSearchCondition.ByControlType(ControlType.TitleBar).OfName(title)
            }));
        }