Exemple #1
0
        /// <summary>Navigates to the new page after navigation action on the current page will be performed.</summary>
        /// <typeparam name="TNewPage">The new page type.</typeparam>
        /// <returns>An instance of the new page type.</returns>
        public TNewPage To <TNewPage>() where TNewPage : BasePage, new()
        {
            var webDriver       = this.currentPage.WebDriver;
            var newPageType     = typeof(TNewPage);
            var beforeActionUrl = webDriver.Url;

            this.navigationAction(this.currentPage);

            //TODO: move default timeout to config
            var timeout       = TimeSpan.FromSeconds(5);
            var isWaitSucceed = TryWait.For(() => PageUtil.IsValid(newPageType, webDriver.Url), timeout);

            if (!isWaitSucceed && webDriver.Url.Equals(beforeActionUrl))
            {
                throw new TimeoutException("Timed out after {0}. Waited for url matched '{1}' page.".F(timeout, newPageType.Name));
            }

            return(ContainerFactory.Page <TNewPage>(this.currentPage.WebDriver, this.currentPage.JavaScriptExecutor));
        }
 /// <summary>
 /// Try wait until the page object is visible on screen .
 /// </summary>
 /// <param name="expectation">Expectation predicate.</param>
 /// <param name="timeout">The timeout.</param>
 /// <returns>Whether the page object is visible on screen.</returns>
 public bool TryWaitFor(Predicate <T> expectation, TimeSpan timeout)
 {
     return(TryWait.For(() => expectation(Value), timeout));
 }
 /// <summary>
 /// Try wait until the page object is visible on screen .
 /// </summary>
 /// <param name="expectation">Expectation predicate.</param>
 /// <returns>Whether the page object is visible on screen.</returns>
 public bool TryWaitFor(Predicate <T> expectation)
 {
     return(TryWait.For(() => expectation(Value), waitTimeout()));
 }