Exemplo n.º 1
0
        public void RunTest()
        {
            var frameworksToRun = SupportedFrameworks();

            foreach (var framework in frameworksToRun)
            {
                currentFramework = framework;
                using (SetMainWindow(framework))
                {
                    try
                    {
                        RunTest(framework);
                    }
                    catch (TestFailedException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new TestFailedException(string.Format("Failed to run test for {0}", framework), ex);
                    }
                }
            }
            currentFramework = null;
        }
Exemplo n.º 2
0
        private void GetMultipleButtons(WindowsFramework framework)
        {
            MainWindow.Get<Button>("GetMultipleButton").Click();
            var window = MainWindow.ModalWindow("GetMultiple");

            try
            {
                var buttons = window.GetMultiple(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Button")).OfType<Button>();
                Assert.AreEqual(3, buttons.Count());

                if (framework == WindowsFramework.Wpf)
                {
                    buttons = window.GetMultiple(SearchCriteria.ByAutomationId("Test")).OfType<Button>();
                    Assert.AreEqual(3, buttons.Count());
                }

                var checkboxes = window.GetMultiple(SearchCriteria.ByControlType(ControlType.CheckBox)).OfType<CheckBox>();
                Assert.AreEqual(3, checkboxes.Count());

                checkboxes = window.GetMultiple(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Checkbox")).OfType<CheckBox>();
                Assert.AreEqual(3, checkboxes.Count());

                if (framework == WindowsFramework.Wpf)
                {
                    checkboxes = window.GetMultiple(SearchCriteria.ByAutomationId("Test2")).OfType<CheckBox>();
                    Assert.AreEqual(3, checkboxes.Count());
                }
            }
            finally
            {
                window.Close();
            }
        }
Exemplo n.º 3
0
 protected override void RunTest(WindowsFramework framework)
 {
     listBoxUnderTest = MainWindow.Get<ListBox>("CheckedListBox");
     RunTest(CanCheckItem);
     RunTest(CheckSelectedItem);
     RunTest(CheckUncheckItem);
 }
Exemplo n.º 4
0
 protected override void RunTest(WindowsFramework framework)
 {
     var window = OpenVerticalSliderWindow();
     using (new DelegateDisposable(() => CloseSliderWindow(window)))
     {
         RunTest(() => Find(window));
         RunTest(() => Slide(window));
     }
 }
Exemplo n.º 5
0
        protected override void RunTest(WindowsFramework framework)
        {
            DataGridUnderTest = MainWindow.Get<ListView>(SearchCriteria.ByAutomationId("DataGridControl"));
            var customControl = MainWindow.Get(SearchCriteria.ByAutomationId("CustomDataGridControl")) as UIItem;
            DataGridFromCustomControlUnderTest = customControl.Get<ListView>(SearchCriteria.ByAutomationId("DataGridControl"));

            RunTest(() => CanGetAllItems(DataGridUnderTest));
            RunTest(() => CanGetAllItems(DataGridFromCustomControlUnderTest));
            RunTest(() => CanGetCell(DataGridUnderTest));
            RunTest(() => CanGetCell(DataGridFromCustomControlUnderTest));
        }
Exemplo n.º 6
0
 protected override void RunTest(WindowsFramework framework)
 {
     CoreAppXmlConfiguration.Instance.LoggerFactory = new ConsoleFactory(LoggerLevel.Debug);
     ComboBoxUnderTest = MainWindow.Get<ComboBox>(SearchCriteria.ByAutomationId("AComboBox"));
     RunTest(ListItemInComboBoxWithoutTextAvailableInitially, WindowsFramework.Wpf);
     RunTest(CanSelectItemAtTopOfList);
     RunTest(CanGetAllItems);
     RunTest(CanSelectItemAtBottomOfList);
     RunTest(CanSelectItemAtTopOfList); // Once an item is selected at the bottom of the list, White couldn't select at the top again
     RunTest(CanSelectByIndex);
     RunTest(CanSelectReallyLongText);
     RunTest(SetValue);
 }
        internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
        {
            SpecializedWindowFactory specializedWindowFactory = specializedWindowFactories.Find(factory => factory.DoesSpecializedThis(element));
            if (specializedWindowFactory != null)
            {
                return specializedWindowFactory.Create(element, option, windowSession);
            }

            var windowsFramework = new WindowsFramework(element.Current.FrameworkId);
            if (windowsFramework.WinForm) return new WinFormWindow(element, option, windowSession);
            if (windowsFramework.WPF) return new WPFWindow(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.Win32) return new Win32Window(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.UIAutomationBug) return null;
            throw new UIItemSearchException(string.Format("{0} is not supported yet.", windowsFramework));
        }
Exemplo n.º 8
0
 private static SearchCriteria SearchCondition(FieldInfo fieldInfo, WindowsFramework framework)
 {
     SearchCriteria defaultCriteria = SearchCriteria.ByAutomationId(fieldInfo.Name).AndControlType(fieldInfo.FieldType, framework);
     SearchCriteria searchCriteria = null;
     object[] customAttributes = fieldInfo.GetCustomAttributes(false);
     foreach (Attribute customAttribute in customAttributes)
     {
         var searchCriteriaAttribute = customAttribute as SearchCriteriaAttribute;
         if (searchCriteriaAttribute != null)
         {
             if (searchCriteria == null) searchCriteria = SearchCriteria.ByControlType(fieldInfo.FieldType, framework);
             searchCriteriaAttribute.Apply(searchCriteria);
         }
     }
     return searchCriteria ?? defaultCriteria;
 }
Exemplo n.º 9
0
 public static TestConfiguration Create(WindowsFramework framework)
 {
     switch (framework.FrameworkId)
     {
         case Constants.WPFFrameworkId:
             return new WpfTestConfiguration();
         case Constants.WinFormFrameworkId:
             return new WinformsTestConfiguration();
         case Constants.SilverlightFrameworkId:
             return new SilverlightTestConfiguration();
         case Constants.Win32FrameworkId:
         case Constants.SWT:
         //case Constants.WinRT:
         default:
             throw new ArgumentOutOfRangeException("framework");
     }
 }
Exemplo n.º 10
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(can_click_on_elements_located_by_searching_through_several_containers);
 }
Exemplo n.º 11
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(SelectUnselect);
     RunTest(CheckAndUncheckCheckbox);
 }
Exemplo n.º 12
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(() => GetMultipleButtons(framework));
 }
Exemplo n.º 13
0
 protected abstract void RunTest(WindowsFramework framework);
Exemplo n.º 14
0
 protected WindowsConfiguration(WindowsFramework framework)
 {
     this.framework = framework;
 }
Exemplo n.º 15
0
        private IDisposable SetMainWindow(WindowsFramework framework)
        {
            try
            {
                Keyboard = Keyboard.Instance;
                var configuration = TestConfigurationFactory.Create(framework);
                Application = configuration.LaunchApplication();
                MainWindow = configuration.GetMainWindow(Application);

                return new ShutdownApplicationDisposable(this);
            }
            catch (Exception e)
            {
                logger.Error("Failed to launch application and get main window", e);
                if (Application != null)
                    Application.Close();
                throw;
            }
        }
Exemplo n.º 16
0
 protected override void RunTest(WindowsFramework framework)
 {
     ComboBoxUnderTest = MainWindow.Get<ComboBox>("DataBoundComboBox");
     RunTest(CanSelectDataboundItems);
 }
Exemplo n.º 17
0
 public FrameworkIdAttribute(WindowsFramework framework)
 {
     this.framework = framework;
 }
Exemplo n.º 18
0
 protected override void RunTest(WindowsFramework framework)
 {
     ComboBoxUnderTest = MainWindow.Get<ComboBox>("EditableComboBox");
     RunTest(SetValueInEditableComboBox);
     RunTest(SelectItemInEditableComboBox);
 }
Exemplo n.º 19
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(ClickTitleBarClose);
 }
Exemplo n.º 20
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(() => GetDate(DateTime.Today), WindowsFramework.WinForms);
     RunTest(() => GetDate(null), WindowsFramework.Wpf, WindowsFramework.Silverlight);
     RunTest(SetDate);
 }
Exemplo n.º 21
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(CanGetTooltip);
 }
Exemplo n.º 22
0
 public FrameworkIdAttribute(string id)
 {
     framework = new WindowsFramework(id);
 }