示例#1
0
        public void ShouldFindAllMatchingItemsIfRequested()
        {
            var window    = LaunchPetShopWindow();
            var tabs      = window.FindAll <Tab>(FindBy.ControlType(ControlType.TabItem));
            var tabTitles = tabs.Select(t => t.Title).ToList();

            Assert.Contains("Registration", tabTitles);
            Assert.Contains("History", tabTitles);
            Assert.Contains("Basket", tabTitles);
            Assert.Contains("Accessories", tabTitles);
        }
示例#2
0
        public void ShouldFindAnElementBasedOnAProperty()
        {
            var window = LaunchPetShopWindow();
            var basket = window.Find <Tab>(FindBy.WpfText("Basket"));

            AutomationElement comboBoxElement = window.Element.FindFirst(TreeScope.Descendants,
                                                                         new PropertyCondition(AutomationElement.ClassNameProperty,
                                                                                               typeof(ComboBox).Name));
            string comboBoxName = comboBoxElement.GetCurrentPropertyValue(AutomationElement.AutomationIdProperty).ToString();

            var wrapperFactory = new Mock <IWrapAutomationElements>();
            var comboBox       = new ComboBox(comboBoxElement, "aComboBox");

            wrapperFactory.Setup(x => x.Wrap <ComboBox>(comboBoxElement, comboBoxName)).Returns(comboBox);

            var finder = new ConditionBasedFinder(wrapperFactory.Object, new Mock <IDescribeConditions>().Object);

            finder.Find <ComboBox>(basket, FindBy.ControlType(ControlType.ComboBox), Assert.Fail);
        }
示例#3
0
        public void ShouldFindWindowByCondition()
        {
            Application application = new ApplicationLauncher().LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, Assert.Fail);
            Window      window      = application.FindWindow(new AndCondition(
                                                                 FindBy.WpfName("petShopWindow"), FindBy.ControlType(ControlType.Window)));

            Assert.IsNotNull(window.Element);
        }