/// <summary> /// Searches for a given child element with the passed By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <typeparam name="TControl">The UI element type to search for.</typeparam> /// <param name="basicElement">The current basic element.</param> /// <param name="by">Provides the conditions to be used by searching the UI element.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static TControl GetChild <TControl>(this BasicElement basicElement, By by, With with) where TControl : BasicElement { return(UI.GetChild <TControl>(by, From.Element(basicElement), with)); }
/// <summary> /// Searches for a given child element with the passed By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <param name="basicElement">The current basic element.</param> /// <param name="by">Provides the conditions to be used by searching the UI element.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static BasicElement GetChild(this BasicElement basicElement, By by, With with) { return(UI.GetChild(by, From.Element(basicElement), with)); }
/// <summary> /// Returns the parent element of the current basic element. If not disabled With.Assert().And.Timeout(10000) gets appended. /// </summary> /// <param name="basicElement">The current basic element.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found parent control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static BasicElement GetParent(this BasicElement basicElement, With with) { return(UI.GetParent(From.Element(basicElement), with)); }
/// <summary> /// Returns the parent element of the current basic element. By default With.Assert().And.Timeout(10000) is in use. /// </summary> /// <typeparam name="TControl">The UI element type to search for.</typeparam> /// <param name="basicElement">The current basic element.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The available parent control if any; otherwise an exception.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found.</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static TControl GetParent <TControl>(this BasicElement basicElement, With with) where TControl : BasicElement { return(UI.GetParent <TControl>(From.Element(basicElement), with)); }
/// <summary> /// Returns all child elements which passes the By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <typeparam name="TControl">The UI element types to search for.</typeparam> /// <param name="basicElement">The current basic element.</param> /// <param name="by">Provides the conditions to be used by searching the UI elements.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>A list of found child elements if any; otherwise an exception if it is not disabled. If it is disabled an empty list gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">The UI element could not be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static IEnumerable <TControl> GetChildren <TControl>(this BasicElement basicElement, By by, With with) where TControl : BasicElement { return(UI.GetChildren <TControl>(by, From.Element(basicElement), with)); }
/// <summary> /// Returns all child elements which passes the By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <param name="basicElement">The current basic element.</param> /// <param name="by">Provides the conditions to be used by searching the UI elements.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>A list of found child elements if any; otherwise an exception if it is not disabled. If it is disabled an empty list gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">The UI element could not be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static IEnumerable <BasicElement> GetChildren(this BasicElement basicElement, By by, With with) { return(UI.GetChildren(by, From.Element(basicElement), with)); }
/// <summary> /// Searches for a given child element with the passed By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <typeparam name="TControl">The UI element type to search for.</typeparam> /// <param name="by">Provides the conditions to be used by searching the UI element.</param> /// <param name="from">The source where the search of the child UI element has to start from.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static TControl GetChild <TControl>(By by, From from, With with) where TControl : BasicElement { return(StartSearchChild <TControl>(by, from, with)); }
/// <summary> /// Searches for a given child element with the passed By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <param name="by">Provides the conditions to be used by searching the UI element.</param> /// <param name="from">The source where the search of the child UI element has to start from.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static BasicElement GetChild(By by, From from, With with) { return(StartSearchChild <BasicElement>(by, from, with)); }
/// <summary> /// Returns the parent element of the given source. By default With.Assert().And.Timeout(10000) is in use. /// </summary> /// <typeparam name="TControl">The UI element type to search for.</typeparam> /// <param name="from">The source from where to start reading the parent elements.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The available parent control if any; otherwise an exception.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found.</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static TControl GetParent <TControl>(From from, With with) where TControl : BasicElement { return(StartSearchParent <TControl>(By.Condition(e => true), from, with)); }
/// <summary> /// Returns the parent element of the given source. By default With.Assert().And.Timeout(10000) is in use. /// </summary> /// <param name="by">Provides the conditions to be used by searching the UI element.</param> /// <param name="from">The source from where to start reading the parent elements.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The available parent control if any; otherwise an exception.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found.</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static BasicElement GetParent(By by, From from, With with) { return(StartSearchParent <BasicElement>(by, from, with)); }
/// <summary> /// Returns the parent element of the given source. If not disabled With.Assert().And.Timeout(10000) gets appended. /// </summary> /// <param name="from">The source from where to start reading the parent elements.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>The found parent control if any; otherwise an exception if it is not disabled. If it is disabled null gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">No UI element could be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static BasicElement GetParent(From from, With with) { return(StartSearchParent <BasicElement>(By.Condition(e => true), from, with)); }
/// <summary> /// Returns all available child elements, no matter their position the child tree, as a plain list. /// </summary> /// <typeparam name="TControl">The UI element types.</typeparam> /// <param name="from">The source where the child elements belongs to.</param> /// <returns>A list of all available child elements.</returns> public static IEnumerable <TControl> GetDescendants <TControl>(From from) where TControl : BasicElement { return(GetChildren <TControl>(By.Condition(p => true), from, With.NoAssert().NoTimeout().NoInterval())); }
private static IEnumerable <TControl> StartSearchChildren <TControl>(By by, From from, With with) where TControl : BasicElement { var condition = by.GetCondition(); var rawCondition = by.GetRawCondition(); var sourceElement = from.GetSourceElement(); var settings = with.GetConditions(); var useTimeout = settings.Contains(WithCondition.Timeout); var timeout = with.GetTimeout(); var assertResult = settings.Contains(WithCondition.Assert); var useInterval = settings.Contains(WithCondition.Interval); var interval = with.GetInterval(); var needsToBeReady = settings.Contains(WithCondition.ReadyToUse); if (CodedUIEnvironment.LoggerSettings.ShortLogging) { LogPool.Append("Search for UI elements. {0}", by.GetConditionDescription()); } else { LogPool.Append("Search for UI elements down from '{0}'. {1}", sourceElement, MessageBuilder.BuildMessage(by, useTimeout, useInterval, timeout, interval)); } var foundItems = new List <TControl>(); var watch = new Stopwatch(); watch.Start(); while (true) { foundItems.AddRange(StartSearchChildren <TControl>(sourceElement, condition, rawCondition)); if (foundItems.Any()) { if (!needsToBeReady) { LogPool.Append("{0} element(s) found.", foundItems.Count); return(foundItems); } for (var i = 0; i < foundItems.Count; ++i) { var foundItem = foundItems[i]; var readyElement = ReturnIfReady(assertResult, by, useTimeout, useInterval, timeout, watch, interval, true, foundItem); if (readyElement == null) { foundItems.RemoveAt(i); --i; } } } if (!useTimeout || watch.Elapsed.TotalMilliseconds >= timeout) { if (assertResult) { throw new UIElementNotFoundException(by, useTimeout, useInterval, interval, watch.Elapsed, true); } return(foundItems); } if (useInterval) { Thread.Sleep((int)interval); } } }
/// <summary> /// Returns all child elements which passes the By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <param name="by">Provides the conditions to be used by searching the UI elements.</param> /// <param name="from">The source where the search of the child UI elements has to start from.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>A list of found child elements if any; otherwise an exception if it is not disabled. If it is disabled an empty list gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">The UI element could not be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static IEnumerable <BasicElement> GetChildren(By by, From from, With with) { return(StartSearchChildren <BasicElement>(by, from, with)); }
/// <summary> /// Returns all child elements which passes the By conditions and With settings. If not disabled With.Timeout(10000).And.Assert() gets appended. /// </summary> /// <typeparam name="TControl">The UI element types to search for.</typeparam> /// <param name="by">Provides the conditions to be used by searching the UI elements.</param> /// <param name="from">The source where the search of the child UI elements has to start from.</param> /// <param name="with">The settings to be used while searching.</param> /// <returns>A list of found child elements if any; otherwise an exception if it is not disabled. If it is disabled an empty list gets returned.</returns> /// <exception cref="DW.CodedUI.UIElementNotFoundException">The UI element could not be found. (If not disabled.)</exception> /// <remarks>To change the default With settings globaly consider changing the values in the <see cref="DW.CodedUI.CodedUIEnvironment" />.</remarks> public static IEnumerable <TControl> GetChildren <TControl>(By by, From from, With with) where TControl : BasicElement { return(StartSearchChildren <TControl>(by, from, with)); }