Esempio n. 1
0
        /// <summary>
        /// Wrapper for BrowserSession.TryUntil that allows the use of a bool Func until instead of a PredicateQuery
        /// </summary>
        /// <remarks>
        /// This version of the TryUntil method allows the caller to override the options used for the action and until
        /// This version of the TryUntil method is not typically used, refer to:
        /// TryUntil(this BrowserSession browserSession, Action action, Func<bool> until)
        /// </remarks>
        /// <param name="browserSession">The browser session.</param>
        /// <param name="action">The action, typically a lambda expression like () => { ... }.</param>
        /// <param name="actionOptions">The action options</param>
        /// <param name="until">The until, typically a lambda expression like () => { ... }.</param>
        /// /// <param name="tryUntilOptions">The try until options</param>
        public static void TryUntil(this BrowserSession browserSession, Action action, Options actionOptions, Func <bool> until, Options tryUntilOptions)
        {
            var browserAction = new LambdaBrowserAction(action, actionOptions);
            var predicate     = new LambdaPredicateQuery(until, new Options()); // options can't be null despite being optional

            browserSession.TryUntil(browserAction, predicate, tryUntilOptions);
        }
Esempio n. 2
0
        /// <summary>
        /// Wrapper for BrowserSession.TryUntil that defaults to a "do nothing" action for instances when the action already occurred,
        /// there is no need to repeat the action, and the caller is simply waiting for the side effect to occur (until).
        /// A bool Func is passed in instead of a PredicateQuery for the until parameter.
        /// </summary>
        /// <param name="browserSession">The browser session.</param>
        /// <param name="until">The until condition to wait for as a function that returns a bool.</param>
        /// <param name="descriptionForError">Provide a helpful description for troubleshooting timeouts</param>
        /// <param name="options">The options used for the call to Coypu.TryUntil, optional.</param>
        public static void WaitUntil(this BrowserSession browserSession, Func <bool> until, string descriptionForError, Options options = null)
        {
            var doNothing = new LambdaBrowserAction(() => { }, new Options()); // options can't be null
            var predicate = new LambdaPredicateQuery(until, new Options());    // options can't be null despite being optional

            try
            {
                browserSession.TryUntil(doNothing, predicate, options ?? new Options());
            }
            catch (Exception e)
            {
                throw new TimeoutException(descriptionForError, e);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Can be called to wait for IsLoaded to fire.
 /// </summary>
 /// <returns>TView</returns>
 public virtual TView WaitToLoad()
 {
     try
     {
         if (IsLoaded())
         {
             return(this as TView);            // Load, so just immediately return this
         }
         var doNothing = new LambdaBrowserAction(() => {}, _NONE);
         var predicate = new LambdaPredicateQuery(IsLoaded, _NONE);
         _browserScope.TryUntil(doNothing, predicate);
     }
     catch (Exception e)
     {
         throw new ZukiniAssertionException($"Expected '{typeof(TView)}' failed to load.\nReason: {e}");
     }
     return(this as TView);
 }