Ejemplo n.º 1
0
        /// <summary>
        /// Creates the native page.
        /// </summary>
        /// <param name="pageType">Type of the page.</param>
        /// <param name="verifyPageValidity">if set to <c>true</c> verify the page validity.</param>
        /// <returns>The created page object.</returns>
        protected override IPage CreateNativePage(Type pageType, bool verifyPageValidity)
        {
            var webDriver = this.driver.Value;

            // Check to see if a frames reference exists, and switch if needed
            PageNavigationAttribute navigationAttribute;

            if (pageType.TryGetAttribute(out navigationAttribute) && !string.IsNullOrWhiteSpace(navigationAttribute.FrameName))
            {
                webDriver.SwitchTo().Frame(navigationAttribute.FrameName);
                this.switchedContext = true;
            }
            else if (this.switchedContext)
            {
                webDriver.SwitchTo().DefaultContent();
                this.switchedContext = false;
            }

            Func <IWebDriver, IBrowser, Action <object>, object> pageBuildMethod;

            if (!this.pageCache.TryGetValue(pageType, out pageBuildMethod))
            {
                pageBuildMethod = pageBuilder.CreatePage(pageType);
                this.pageCache.Add(pageType, pageBuildMethod);
            }

            var nativePage = pageBuildMethod(webDriver, this, null);

            return(new SeleniumPage(nativePage));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the builder function.
        /// </summary>
        /// <returns>The created builder function.</returns>
        protected Func <ISearchContext, IBrowser, Action <object>, object> CreateBuilderFunction()
        {
            var builder = new SeleniumPageBuilder();

            return(builder.CreatePage(typeof(TChildElement)));
        }