/// <summary> /// Opens the project page tab via the start page 'New project' button. /// </summary> /// <param name="application">The application.</param> /// <param name="log">The log object.</param> /// <exception cref="RegressionTestFailedException"> /// Thrown if the 'New project' button could not be invoked for some reason. /// </exception> public static void OpenProjectPageViaWelcomePageButton(Application application, Log log) { const string prefix = "Welcome page - Open project"; var startPage = TabProxies.GetStartPageTabItem(application, log); if (startPage == null) { throw new RegressionTestFailedException(prefix + ": Failed to get the start page."); } try { if (!startPage.IsSelected) { log.Debug(prefix, "Selecting start page."); startPage.Select(); } } catch (Exception e) { throw new RegressionTestFailedException(prefix + ": Failed to select the start page.", e); } var newProjectSearchCriteria = SearchCriteria .ByAutomationId(WelcomeViewAutomationIds.NewProject) .AndControlType(ControlType.Button); var newProjectButton = Retry.Times( () => { log.Debug(prefix, "Trying to get 'New project' button."); var button = (Button)startPage.Get(newProjectSearchCriteria); if (button == null) { log.Error(prefix, "Failed to get 'New project' button."); } return(button); }); if (newProjectButton == null) { newProjectButton = (Button)ControlProxies.FindItemManuallyInUIContainer( startPage as UIItemContainer, WelcomeViewAutomationIds.NewProject, log); if (newProjectButton == null) { throw new RegressionTestFailedException(prefix + ": Failed to get the 'New project' button."); } } try { newProjectButton.Click(); } catch (Exception e) { throw new RegressionTestFailedException(prefix + ": Failed to click the 'New project' button.", e); } }
private static SortedList <int, IUIItem> GetDatasetControls(Application application, Log log) { var tab = TabProxies.GetProjectPageTabItem(application, log); if (tab == null) { return(new SortedList <int, IUIItem>()); } var partialId = string.Format( CultureInfo.InvariantCulture, "Vertex_[{0}_[DatasetId: [", DatasetViewAutomationIds.GraphVertex); var controls = ControlProxies.FindItemsManuallyInUIContainerWithPartialId((UIItemContainer)tab, partialId, log); var result = new SortedList <int, IUIItem>(); foreach (var control in controls) { var idText = control.Id.Substring(partialId.Length).TrimEnd(']'); int id; if (int.TryParse(idText, out id)) { result.Add(id, control); } } return(result); }
/// <summary> /// Checks the 'Keep welcome page open' checkbox. /// </summary> /// <param name="application">The application.</param> /// <param name="log">The log object.</param> /// <exception cref="RegressionTestFailedException"> /// Thrown if the 'Keep welcome page open' checkbox could not be checked for some reason. /// </exception> public static void CheckCloseWelcomePageOnProjectOpen(Application application, Log log) { const string prefix = "Welcome page - Check close welcome page on project open"; var startPage = TabProxies.GetStartPageTabItem(application, log); if (startPage == null) { MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log); } startPage = TabProxies.GetStartPageTabItem(application, log); if (startPage == null) { throw new RegressionTestFailedException(prefix + ": Failed to get start page."); } try { if (!startPage.IsSelected) { log.Debug(prefix, "Selecting start page."); startPage.Select(); } } catch (Exception e) { throw new RegressionTestFailedException( prefix + ": Failed to select the start page", e); } // Check 'keep open' flag var closePageSearchCriteria = SearchCriteria .ByAutomationId(WelcomeViewAutomationIds.ClosePageAfterLoad) .AndControlType(ControlType.CheckBox); var closePageCheckBox = Retry.Times( () => { log.Debug(prefix, "Trying to get checkbox."); var checkBox = (CheckBox)startPage.Get(closePageSearchCriteria); if (checkBox == null) { log.Error(prefix, "Failed to get checkbox."); } return(checkBox); }); if (closePageCheckBox == null) { closePageCheckBox = (CheckBox)ControlProxies.FindItemManuallyInUIContainer( startPage as UIItemContainer, WelcomeViewAutomationIds.ClosePageAfterLoad, log); if (closePageCheckBox == null) { throw new RegressionTestFailedException(prefix + ": Failed to get checkbox."); } } try { if (!closePageCheckBox.Checked) { log.Debug(prefix, "Checking 'Close welcome page on project open' checkbox."); closePageCheckBox.Checked = true; } } catch (Exception e) { throw new RegressionTestFailedException( prefix + ": Failed to check the 'Keep start page open' checkbox.", e); } }
/// <summary> /// Unchecks the 'Show welcome page on application start' checkbox. /// </summary> /// <param name="application">The application.</param> /// <param name="log">The log object.</param> /// <exception cref="RegressionTestFailedException"> /// Thrown if the 'Show welcome page on application start' checkbox could not be unchecked for some reason. /// </exception> public static void UncheckShowWelcomePageOnApplicationStart(Application application, Log log) { const string prefix = "Welcome page - Uncheck show page on start"; var startPage = TabProxies.GetStartPageTabItem(application, log); if (startPage == null) { MenuProxies.SwitchToStartPageViaViewStartPageMenuItem(application, log); } startPage = TabProxies.GetStartPageTabItem(application, log); if (startPage == null) { throw new RegressionTestFailedException(prefix + ": Failed to get start page."); } try { if (!startPage.IsSelected) { log.Debug(prefix, "Selecting start page."); startPage.Select(); } } catch (Exception e) { throw new RegressionTestFailedException(prefix + " - Failed to select the start page", e); } // Check 'Show welcome page on application start' flag var showStartPageSearchCriteria = SearchCriteria .ByAutomationId(WelcomeViewAutomationIds.ShowPageOnStartup) .AndControlType(ControlType.CheckBox); var showStartPageCheckBox = Retry.Times( () => { log.Debug(prefix, "Trying to get checkbox."); var checkBox = (CheckBox)startPage.Get(showStartPageSearchCriteria); if (checkBox == null) { log.Error(prefix, "Failed to get checkbox."); } return(checkBox); }); if (showStartPageCheckBox == null) { showStartPageCheckBox = (CheckBox)ControlProxies.FindItemManuallyInUIContainer( startPage as UIItemContainer, WelcomeViewAutomationIds.ShowPageOnStartup, log); if (showStartPageCheckBox == null) { throw new RegressionTestFailedException(prefix + ": Failed to get checkbox."); } } try { if (showStartPageCheckBox.Checked) { log.Debug(prefix, "Unchecking 'Show welcome page on application start' checkbox."); showStartPageCheckBox.Checked = false; } } catch (Exception e) { throw new RegressionTestFailedException( prefix + " - Failed to uncheck the 'Show welcome page on application start' checkbox.", e); } }
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); } }