Click or drag to resize

SearchContextExtensionsGetElementT Method (ISearchContext, ElementLocator, Double, FuncIWebElement, Boolean, String)

Framework to automate tests using Selenium WebDriver
Finds and waits for an element that meets specified conditions at specified time.

Namespace:  Ocaramba.Extensions
Assembly:  OcarambaLite (in OcarambaLite.dll) Version: 3.3.1
Syntax
C#
public static T GetElement<T>(
	this ISearchContext searchContext,
	ElementLocator locator,
	double timeout,
	Func<IWebElement, bool> condition,
	[OptionalAttribute] string customMessage
)
where T : class, IWebElement

Parameters

searchContext
Type: OpenQA.SeleniumISearchContext
The search context.
locator
Type: Ocaramba.TypesElementLocator
The locator.
timeout
Type: SystemDouble
Specified time to wait.
condition
Type: SystemFuncIWebElement, Boolean
The condition to be met.
customMessage (Optional)
Type: SystemString
Custom message to be displayed when there is no possible to get element.

Type Parameters

T
IWebComponent like ICheckbox, ISelect, etc.

Return Value

Type: T
Located and displayed element.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ISearchContext. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Examples
How to specify element type to get additional actions for it and specify time and condition to find this element:
var checkbox = this.Driver.GetElement<Checkbox>(this.stackOverFlowCheckbox, timeout, e => e.Displayed);
checkbox.TickCheckbox();
See Also