示例#1
0
        /// <summary>
        /// Closes the window specified in the given <paramref name="context"/>.
        /// </summary>
        public static void CloseWindow([NotNull] this PageObjectContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            context.Window.ExecuteScript(CommonJavaScripts.SelfClose);
            EnsureParentWindowIsActive(context);
        }
 private static TPageObject AssertActualMatchesExpectedPageAndReturnNewPageObject <TPageObject> (
     PageObjectContext newPageObjectContext,
     Action <PageObjectContext> actualMatchesExpectedPageAssertion)
     where TPageObject : PageObject
 {
     actualMatchesExpectedPageAssertion(newPageObjectContext);
     return((TPageObject)Activator.CreateInstance(typeof(TPageObject), new object[] { newPageObjectContext }));
 }
        /// <summary>
        /// Returns a new <typeparamref name="TPageObject"/> for the initial page displayed by <paramref name="browser"/>.
        /// </summary>
        public TPageObject CreateInitialPageObject <TPageObject> ([NotNull] BrowserSession browser)
            where TPageObject : PageObject
        {
            ArgumentUtility.CheckNotNull("browser", browser);

            var context = PageObjectContext.New(browser);

            return((TPageObject)Activator.CreateInstance(typeof(TPageObject), new object[] { context }));
        }
        /// <summary>
        /// Private constructor, use <see cref="New"/> to create a new root <see cref="PageObjectContext"/>.
        /// </summary>
        internal PageObjectContext(
            [NotNull] BrowserSession browser,
            [NotNull] BrowserWindow window,
            [NotNull] ElementScope scope,
            [CanBeNull] PageObjectContext parentContext)
            : base(scope)
        {
            ArgumentUtility.CheckNotNull("browser", browser);
            ArgumentUtility.CheckNotNull("window", window);

            _browser       = browser;
            _window        = window;
            _parentContext = parentContext;
        }
示例#5
0
        /// <summary>
        /// WebDriver implementations hang when trying to find an element within an <see cref="ElementScope"/> which is on an already closed window.
        /// Therefore, after closing a window via non-Coypu means, it is important to ensure that a non-closed window is active.
        /// </summary>
        private static void EnsureParentWindowIsActive([NotNull] this PageObjectContext context)
        {
            ArgumentUtility.CheckNotNull("context", context);

            context.ParentContext.Window.EnsureWindowIsActive();
        }