Пример #1
0
        private T GoToFollowingPageObject <T>(
            UIComponent currentPageObject,
            T nextPageObject,
            GoOptions options)
            where T : PageObject <T>
        {
            bool isReturnedFromTemporary = TryResolvePreviousPageObjectNavigatedTemporarily(ref nextPageObject);

            nextPageObject = nextPageObject ?? ActivatorEx.CreateInstance <T>();

            if (!isReturnedFromTemporary)
            {
                if (!options.Temporarily)
                {
                    _context.CleanUpTemporarilyPreservedPageObjectList();
                }

                nextPageObject.NavigateOnInit = options.Navigate;

                if (options.Temporarily)
                {
                    nextPageObject.IsTemporarilyNavigated = options.Temporarily;
                    _context.TemporarilyPreservedPageObjectList.Add(currentPageObject);
                }
            }

            ((IPageObject)currentPageObject).DeInit();

            _context.PageObject = nextPageObject;

            // TODO: Review this condition.
            if (!options.Temporarily)
            {
                UIComponentResolver.CleanUpPageObject(currentPageObject);
            }

            if (!string.IsNullOrWhiteSpace(options.Url))
            {
                Go.ToUrl(options.Url);
            }

            if (!string.IsNullOrWhiteSpace(options.WindowName))
            {
                ((IPageObject)currentPageObject).SwitchToWindow(options.WindowName);
            }

            if (isReturnedFromTemporary)
            {
                _context.Log.Info("Go to {0}", nextPageObject.ComponentFullName);
            }
            else
            {
                nextPageObject.PreviousPageObject = currentPageObject;
                nextPageObject.Init();
            }

            return(nextPageObject);
        }
Пример #2
0
        TOther IPageObject.GoTo <TOther>(TOther pageObject, GoOptions options)
        {
            bool isReturnedFromTemporary = TryResolvePreviousPageObjectNavigatedTemporarily(ref pageObject);

            pageObject = pageObject ?? ActivatorEx.CreateInstance <TOther>();

            if (!isReturnedFromTemporary)
            {
                if (!options.Temporarily)
                {
                    AtataContext.Current.CleanUpTemporarilyPreservedPageObjectList();
                }

                pageObject.NavigateOnInit = options.Navigate;

                if (options.Temporarily)
                {
                    pageObject.IsTemporarilyNavigated = options.Temporarily;
                    AtataContext.Current.TemporarilyPreservedPageObjectList.Add(this);
                }
            }

            ExecuteTriggers(TriggerEvents.DeInit);

            // TODO: Review that condition.
            if (!options.Temporarily)
            {
                UIComponentResolver.CleanUpPageObject(this);
            }

            if (!string.IsNullOrWhiteSpace(options.Url))
            {
                Go.ToUrl(options.Url);
            }

            if (!string.IsNullOrWhiteSpace(options.WindowName))
            {
                SwitchTo(options.WindowName);
            }

            if (isReturnedFromTemporary)
            {
                Log.Info("Go to {0}", pageObject.ComponentFullName);
            }
            else
            {
                pageObject.PreviousPageObject = this;
                pageObject.Init();
            }

            return(pageObject);
        }
Пример #3
0
        /// <summary>
        /// Cleans up the test context.
        /// </summary>
        /// <param name="quitDriver">if set to <c>true</c> quits WebDriver.</param>
        public void CleanUp(bool quitDriver = true)
        {
            if (disposed)
            {
                return;
            }

            ExecuteCleanUpActions();

            TimeSpan cleanTestExecutionTime = DateTime.Now - CleanExecutionStartDateTime;

            Log.Start("Clean up test context");

            CleanUpTemporarilyPreservedPageObjectList();

            if (PageObject != null)
            {
                UIComponentResolver.CleanUpPageObject(PageObject);
            }

            if (quitDriver)
            {
                Driver.Quit();
            }

            Log.EndSection();

            TimeSpan testExecutionTime = DateTime.Now - TestStart;

            Log.InfoWithExecutionTimeInBrackets("Finished test", testExecutionTime);
            Log.InfoWithExecutionTime("Pure test execution time: ", cleanTestExecutionTime);

            Log = null;

            if (Current == this)
            {
                Current = null;
            }

            disposed = true;
        }