Пример #1
0
        /// <summary>
        ///     Find a Modal Window based on SearchCriteria
        /// </summary>
        /// <param name="title">title of the window</param>
        /// <param name="scope">Scope of search</param>
        /// <param name="timeout">Timeout value for search (milliseconds)</param>
        /// <returns>Matching Window</returns>
        private static Window FindModalWindow(string title, Window scope = null, int timeout = 0)
        {
            if (timeout > 0)
            {
                WhiteConfigHelper.OriginalFindUIItemTimeout = timeout;
            }

            if (scope == null)
            {
                scope = WorkSpace.MainWindow.Window;
            }

            Report.Output(Report.Level.Debug, Resources.ModalWindowFindUsingTitleMsg, title, scope.PrimaryIdentification);

            Window matchingWindow = null;
            var    stopwatch      = new Stopwatch();
            var    elapsedTime    = new TimeSpan();

            try
            {
                stopwatch.Start();
                matchingWindow = scope.ModalWindow(title);
                elapsedTime    = stopwatch.Elapsed;
                matchingWindow.WaitWhileBusy();

                Report.Output(Report.Level.Debug, Resources.ModalWindowFoundMsg, elapsedTime);
            }
            catch (AutomationException ex)
            {
                elapsedTime = stopwatch.Elapsed;

                Report.Output(Report.Level.Debug, Resources.ModalWindowNotFoundMsg, elapsedTime, ex.Message);
            }
            finally
            {
                stopwatch.Stop();

                if (timeout > 0)
                {
                    WhiteConfigHelper.ResetFindWindowTimeout();
                }
            }

            return(matchingWindow);
        }
Пример #2
0
        /// <summary>
        ///     Find a Window based on SearchCriteria
        /// </summary>
        /// <param name="searchCriteria">Window identification conditions</param>
        /// <param name="scope">Scope of search</param>
        /// <param name="timeout">Timeout value for search (milliseconds)</param>
        /// <returns>Matching Window</returns>
        private static Window FindWindow(SearchCriteria searchCriteria, Application scope = null, int timeout = 0)
        {
            if (timeout > 0)
            {
                WhiteConfigHelper.OriginalFindUIItemTimeout = timeout;
            }

            if (scope == null)
            {
                scope = WorkSpace.Application.Application;
            }

            Report.Output(Report.Level.Debug, Resources.WindowFindUsingSearchCriteriaMsg, searchCriteria.ToString(), scope.Name);

            Window matchingWindow = null;
            var    stopwatch      = new Stopwatch();
            var    elapsedTime    = new TimeSpan();

            try
            {
                stopwatch.Start();
                matchingWindow = scope.GetWindow(searchCriteria, InitializeOption.NoCache);
                elapsedTime    = stopwatch.Elapsed;
                matchingWindow.WaitWhileBusy();

                Report.Output(Report.Level.Debug, Resources.WindowFoundMsg, elapsedTime);
            }
            catch (AutomationException ex)
            {
                elapsedTime = stopwatch.Elapsed;

                Report.Output(Report.Level.Debug, Resources.WindowNotFoundMsg, elapsedTime, ex.Message);
            }
            finally
            {
                stopwatch.Stop();

                if (timeout > 0)
                {
                    WhiteConfigHelper.ResetFindWindowTimeout();
                }
            }

            return(matchingWindow);
        }