/// <summary> /// Returns the main menu of the application. /// </summary> /// <param name="application">The application.</param> /// <param name="log">The log object.</param> /// <returns>The main menu of the application.</returns> public static MenuBar GetMainMenu(Application application, Log log) { const string prefix = "Menus - Get main menu"; var mainWindow = DialogProxies.MainWindow(application, log); if (mainWindow == null) { return(null); } var menuSearchCriteria = SearchCriteria .ByAutomationId(MainMenuAutomationIds.Menu) .AndControlType(ControlType.Menu); return(Retry.Times( () => { log.Debug(prefix, "Trying to get main menu."); var menu = (MenuBar)mainWindow.Get(menuSearchCriteria); if (menu == null) { log.Error(prefix, "Failed to get the main menu."); } return menu; })); }
/// <summary> /// Returns the tab control in the main window of the application. /// </summary> /// <param name="application">The application.</param> /// <param name="log">The log object.</param> /// <returns>The tab control in the main window of the application.</returns> public static Tab GetMainTab(Application application, Log log) { const string prefix = "Tabs - Get main tab control"; var mainWindow = DialogProxies.MainWindow(application, log); if (mainWindow == null) { return(null); } var tabSearchCriteria = SearchCriteria .ByAutomationId(ShellAutomationIds.Tabs); return(Retry.Times( () => { log.Debug(prefix, "Trying to get the main tab control."); var tab = (Tab)mainWindow.Get(tabSearchCriteria); if (tab == null) { log.Error(prefix, "Failed to get the main tab control."); } return tab; })); }
private static void SelectMachineForDatasetActivation(Application application, Log log) { const string prefix = "Project page - Machine selection"; var dialog = DialogProxies.DatasetMachineSelectionWindow(application, log); if (dialog == null) { throw new RegressionTestFailedException(prefix + " - Failed to get the machine selection window."); } var listSearchCriteria = SearchCriteria .ByAutomationId(MachineSelectorViewAutomationIds.AvailableMachines); var list = Retry.Times( () => { log.Debug(prefix, "Trying to get available machines list."); var listBox = dialog.Get <ListBox>(listSearchCriteria); if (listBox == null) { log.Error(prefix, "Failed to get the available machines list."); } return(listBox); }); if (list == null) { list = (ListBox)ControlProxies.FindItemManuallyInUIContainer( dialog, MachineSelectorViewAutomationIds.AvailableMachines, log); if (list == null) { throw new RegressionTestFailedException(prefix + " - Failed to get the available machines list."); } } // Find the item that matches the current machine var item = list.Items.Find(i => string.Equals(Environment.MachineName, i.Text)); if (item == null) { log.Debug( prefix, string.Format( CultureInfo.InvariantCulture, "Expected machine with name [{0}] but found following machines: [{1}]", Environment.MachineName, list.Items.Aggregate( string.Empty, (c, i) => { var next = string.Format( CultureInfo.InvariantCulture, "; [{0}]", i.Text); return(c + next); }))); throw new RegressionTestFailedException(prefix + " - Failed to get the item for the current machine."); } item.Select(); var buttonSearchCriteria = SearchCriteria .ByAutomationId(MachineSelectorViewAutomationIds.ConfirmSelection); var confirmButton = Retry.Times( () => { log.Debug(prefix, "Trying to get confirm button."); var button = dialog.Get <Button>(buttonSearchCriteria); if (button == null) { log.Error(prefix, "Failed to get the confirm button."); } return(button); }); if (confirmButton == null) { confirmButton = (Button)ControlProxies.FindItemManuallyInUIContainer( dialog, MachineSelectorViewAutomationIds.ConfirmSelection, log); if (confirmButton == null) { throw new RegressionTestFailedException(prefix + " - Failed to get the machine selection confirm button."); } } try { confirmButton.Click(); } catch (Exception e) { throw new RegressionTestFailedException(prefix + " - Failed to confirm the machine selection.", e); } }