Class ElementExtensions
Defines a collection of extensions for elements.
Inheritance
Namespace: Legerity.Extensions
Assembly: Legerity.Core.dll
Syntax
public static class ElementExtensions : object
Methods
| Improve this Doc View SourceFindElementByPartialText(IWebElement, String)
Finds the first element in the given element that matches the specified text partially.
Declaration
public static IWebElement FindElementByPartialText(this IWebElement element, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| System.String | text | The partial text to find. |
Returns
| Type | Description |
|---|---|
| IWebElement | A |
FindElementByText(IWebElement, String)
Finds the first element in the given element that matches the specified text.
Declaration
public static IWebElement FindElementByText(this IWebElement element, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| System.String | text | The text to find. |
Returns
| Type | Description |
|---|---|
| IWebElement | A |
FindElementsByPartialText(IWebElement, String)
Finds all the elements in the given element that matches the specified text partially.
Declaration
public static ReadOnlyCollection<IWebElement> FindElementsByPartialText(this IWebElement element, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| System.String | text | The partial text to find. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<IWebElement> | A readonly collection of |
FindElementsByText(IWebElement, String)
Finds all the elements in the given element that matches the specified text.
Declaration
public static ReadOnlyCollection<IWebElement> FindElementsByText(this IWebElement element, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| System.String | text | The text to find. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<IWebElement> | A readonly collection of |
FindWebElement(IWebElement, By)
Finds the first element in the given element that matches the
Declaration
public static RemoteWebElement FindWebElement(this IWebElement element, By locator)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| By | locator | The locator to find the element. |
Returns
| Type | Description |
|---|---|
| RemoteWebElement | A |
FindWebElements(IWebElement, By)
Finds all the elements in the given element that matches the
Declaration
public static ReadOnlyCollection<RemoteWebElement> FindWebElements(this IWebElement element, By locator)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web element. |
| By | locator | The locator to find the elements. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<RemoteWebElement> | A readonly collection of |
GetAllChildElements(IWebElement)
Retrieves all child elements that can be located by the driver for the given element.
Declaration
public static ReadOnlyCollection<IWebElement> GetAllChildElements(this IWebElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The remote web driver. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<IWebElement> | A readonly collection of |
GetBoundingRect(IWebElement)
Determines the bounding rectangle for the specified element.
Declaration
public static Rectangle GetBoundingRect(this IWebElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| IWebElement | element | The element to determine the rect for. |
Returns
| Type | Description |
|---|---|
| Rectangle | The elements bounding rectangle. |
TryWaitUntil(RemoteWebElement, Func<RemoteWebElement, Boolean>, Nullable<TimeSpan>, Int32, Action<Exception>)
Attempts to wait until a specified element condition is met, with an optional timeout.
Declaration
public static bool TryWaitUntil(this RemoteWebElement element, Func<RemoteWebElement, bool> condition, TimeSpan? timeout = null, int retries = 0, Action<Exception> exceptionHandler = null)
Parameters
| Type | Name | Description |
|---|---|---|
| RemoteWebElement | element | The element to wait on. |
| Func<RemoteWebElement, System.Boolean> | condition | The condition of the element to wait on. |
| System.Nullable<TimeSpan> | timeout | The optional timeout wait on the condition being true. |
| System.Int32 | retries | An optional count of retries after a timeout before accepting the failure. |
| Action<Exception> | exceptionHandler | The optional exception handler thrown if an error occurs as a result of timeout. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Whether the wait was a success. |
WaitUntil<TResult>(RemoteWebElement, Func<RemoteWebElement, TResult>, Nullable<TimeSpan>, Int32)
Waits until a specified element condition is met, with an optional timeout.
Declaration
public static TResult WaitUntil<TResult>(this RemoteWebElement element, Func<RemoteWebElement, TResult> condition, TimeSpan? timeout = null, int retries = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| RemoteWebElement | element | The element to wait on. |
| Func<RemoteWebElement, TResult> | condition | The condition of the element to wait on. |
| System.Nullable<TimeSpan> | timeout | The optional timeout wait on the condition being true. |
| System.Int32 | retries | An optional count of retries after a timeout before accepting the failure. |
Returns
| Type | Description |
|---|---|
| TResult | The |
Type Parameters
| Name | Description |
|---|---|
| TResult | The type of expected result from the wait condition. |