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; }
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(); } }
protected override void RunTest(WindowsFramework framework) { listBoxUnderTest = MainWindow.Get<ListBox>("CheckedListBox"); RunTest(CanCheckItem); RunTest(CheckSelectedItem); RunTest(CheckUncheckItem); }
protected override void RunTest(WindowsFramework framework) { var window = OpenVerticalSliderWindow(); using (new DelegateDisposable(() => CloseSliderWindow(window))) { RunTest(() => Find(window)); RunTest(() => Slide(window)); } }
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)); }
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)); }
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; }
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"); } }
protected override void RunTest(WindowsFramework framework) { RunTest(can_click_on_elements_located_by_searching_through_several_containers); }
protected override void RunTest(WindowsFramework framework) { RunTest(SelectUnselect); RunTest(CheckAndUncheckCheckbox); }
protected override void RunTest(WindowsFramework framework) { RunTest(() => GetMultipleButtons(framework)); }
protected abstract void RunTest(WindowsFramework framework);
protected WindowsConfiguration(WindowsFramework framework) { this.framework = framework; }
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; } }
protected override void RunTest(WindowsFramework framework) { ComboBoxUnderTest = MainWindow.Get<ComboBox>("DataBoundComboBox"); RunTest(CanSelectDataboundItems); }
public FrameworkIdAttribute(WindowsFramework framework) { this.framework = framework; }
protected override void RunTest(WindowsFramework framework) { ComboBoxUnderTest = MainWindow.Get<ComboBox>("EditableComboBox"); RunTest(SetValueInEditableComboBox); RunTest(SelectItemInEditableComboBox); }
protected override void RunTest(WindowsFramework framework) { RunTest(ClickTitleBarClose); }
protected override void RunTest(WindowsFramework framework) { RunTest(() => GetDate(DateTime.Today), WindowsFramework.WinForms); RunTest(() => GetDate(null), WindowsFramework.Wpf, WindowsFramework.Silverlight); RunTest(SetDate); }
protected override void RunTest(WindowsFramework framework) { RunTest(CanGetTooltip); }
public FrameworkIdAttribute(string id) { framework = new WindowsFramework(id); }