/// <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); }
/// <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); }
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 } }); }
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)); } }