Class DriverExtensions
Defines a collection of extensions for a driver.
Inheritance
Namespace: Legerity.Extensions
Assembly: Legerity.Core.dll
Syntax
public static class DriverExtensions : object
Methods
| Improve this Doc View SourceFindElementByPartialText(RemoteWebDriver, String)
Finds the first element in the page that matches the specified text partially.
Declaration
public static IWebElement FindElementByPartialText(this RemoteWebDriver driver, string text)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
System.String | text | The partial text to find. |
Returns
Type | Description |
---|---|
IWebElement | A |
FindElementByText(RemoteWebDriver, String)
Finds the first element in the page that matches the specified text.
Declaration
public static IWebElement FindElementByText(this RemoteWebDriver driver, string text)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
System.String | text | The text to find. |
Returns
Type | Description |
---|---|
IWebElement | A |
FindElementsByPartialText(RemoteWebDriver, String)
Finds all the elements in the page that matches the specified text partially.
Declaration
public static ReadOnlyCollection<IWebElement> FindElementsByPartialText(this RemoteWebDriver driver, string text)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
System.String | text | The partial text to find. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<IWebElement> | A readonly collection of |
FindElementsByText(RemoteWebDriver, String)
Finds all the elements in the page that matches the specified text.
Declaration
public static ReadOnlyCollection<IWebElement> FindElementsByText(this RemoteWebDriver driver, string text)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
System.String | text | The text to find. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<IWebElement> | A readonly collection of |
FindWebElement(RemoteWebDriver, By)
Finds the first element in the page that matches the
Declaration
public static RemoteWebElement FindWebElement(this RemoteWebDriver driver, By locator)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
By | locator | The locator to find the element. |
Returns
Type | Description |
---|---|
RemoteWebElement | A |
FindWebElements(RemoteWebDriver, By)
Finds all the elements in the page that matches the
Declaration
public static ReadOnlyCollection<RemoteWebElement> FindWebElements(this RemoteWebDriver driver, By locator)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
By | locator | The locator to find the elements. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<RemoteWebElement> | A readonly collection of |
GetAllChildElements(RemoteWebDriver)
Retrieves all child elements that can be located by the driver in the page.
Declaration
public static ReadOnlyCollection<IWebElement> GetAllChildElements(this RemoteWebDriver driver)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<IWebElement> | A readonly collection of |
GetAllElements(RemoteWebDriver)
Retrieves all elements that can be located by the driver in the page.
Declaration
public static ReadOnlyCollection<IWebElement> GetAllElements(this RemoteWebDriver driver)
Parameters
Type | Name | Description |
---|---|---|
RemoteWebDriver | driver | The remote web driver. |
Returns
Type | Description |
---|---|
ReadOnlyCollection<IWebElement> | A readonly collection of |
TryWaitUntil(IWebDriver, Func<IWebDriver, Boolean>, Nullable<TimeSpan>, Int32, Action<Exception>)
Attempts to wait until a specified driver condition is met, with an optional timeout.
Declaration
public static bool TryWaitUntil(this IWebDriver appDriver, Func<IWebDriver, bool> condition, TimeSpan? timeout = null, int retries = 0, Action<Exception> exceptionHandler = null)
Parameters
Type | Name | Description |
---|---|---|
IWebDriver | appDriver | The driver to wait on. |
Func<IWebDriver, 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>(IWebDriver, Func<IWebDriver, TResult>, Nullable<TimeSpan>, Int32)
Waits until a specified driver condition is met, with an optional timeout.
Declaration
public static TResult WaitUntil<TResult>(this IWebDriver appDriver, Func<IWebDriver, TResult> condition, TimeSpan? timeout = null, int retries = 0)
Parameters
Type | Name | Description |
---|---|---|
IWebDriver | appDriver | The driver to wait on. |
Func<IWebDriver, 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. |