コード例 #1
0
ファイル: UIComponent`1.cs プロジェクト: rputch/atata
        /// <summary>
        /// Waits until the specified component condition is met.
        /// </summary>
        /// <param name="until">The waiting condition.</param>
        /// <param name="options">The options.</param>
        /// <returns>The instance of the owner page object.</returns>
        public TOwner Wait(Until until, WaitOptions options = null)
        {
            foreach (WaitUnit unit in until.GetWaitUnits(options))
            {
                Log.ExecuteSection(
                    new WaitForComponentLogSection(this, unit),
                    () => OnWait(unit));
            }

            return(Owner);
        }
コード例 #2
0
ファイル: UIComponent`1.cs プロジェクト: jetstreamin/atata
        /// <summary>
        /// Waits until the specified component condition is met.
        /// </summary>
        /// <param name="until">The waiting condition.</param>
        /// <param name="options">The options.</param>
        /// <returns>The instance of the owner page object.</returns>
        public TOwner Wait(Until until, WaitOptions options = null)
        {
            foreach (WaitUnit unit in until.GetWaitUnits(options))
            {
                Log.Start(new WaitForComponentLogSection(this, unit));

                OnWait(unit);

                Log.EndSection();
            }

            return(Owner);
        }
コード例 #3
0
 private static WaitUnit CreatePresenceUnit(Visibility visibility, Until until, WaitOptions options)
 {
     return(new WaitUnit
     {
         Method = WaitUnit.WaitMethod.Presence,
         Until = until,
         SearchOptions = new SearchOptions
         {
             Timeout = TimeSpan.FromSeconds(options.PresenceTimeout),
             RetryInterval = TimeSpan.FromSeconds(options.RetryInterval),
             Visibility = visibility,
             IsSafely = !options.ThrowOnPresenceFailure
         }
     });
 }
コード例 #4
0
        public static WaitUnit[] GetWaitUnits(this Until until, WaitOptions options = null)
        {
            if (options == null)
            {
                options = new WaitOptions();
            }

            switch (until)
            {
            case Until.Missing:
                return(new[]
                {
                    CreateAbsenceUnit(Visibility.Any, until, options)
                });

            case Until.Hidden:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Hidden, until, options)
                });

            case Until.MissingOrHidden:
                return(new[]
                {
                    CreateAbsenceUnit(Visibility.Visible, until, options)
                });

            case Until.Visible:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Visible, until, options)
                });

            case Until.VisibleOrHidden:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Any, until, options)
                });

            case Until.VisibleThenHidden:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Visible, until, options),
                    CreatePresenceUnit(Visibility.Hidden, until, options)
                });

            case Until.VisibleThenMissing:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Visible, until, options),
                    CreateAbsenceUnit(Visibility.Any, until, options)
                });

            case Until.VisibleThenMissingOrHidden:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Visible, until, options),
                    CreateAbsenceUnit(Visibility.Visible, until, options)
                });

            case Until.MissingThenVisible:
                return(new[]
                {
                    CreateAbsenceUnit(Visibility.Any, until, options),
                    CreatePresenceUnit(Visibility.Visible, until, options)
                });

            case Until.HiddenThenVisible:
                return(new[]
                {
                    CreatePresenceUnit(Visibility.Hidden, until, options),
                    CreatePresenceUnit(Visibility.Visible, until, options)
                });

            case Until.MissingOrHiddenThenVisible:
                return(new[]
                {
                    CreateAbsenceUnit(Visibility.Visible, until, options),
                    CreatePresenceUnit(Visibility.Visible, until, options)
                });

            default:
                throw ExceptionFactory.CreateForUnsupportedEnumValue(until, nameof(until));
            }
        }