コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        /// <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);
            }
        }