OnScreenElement Methods
CloneForMultipleInstances
This method is used to clone an element when finding all instances with FindAllInstances. The returned elements are in general shallow clones of the original element, however for elements with sub-elements (e.g. LabelWithCheckbox) those should be cloned in an override.
Syntax:
Return Value:
A clone of the element.
FindAllInstances
Finds all instances of the element that are visible on the screen and returns them as a list of OnScreenElement. The returned elements all have UseCachedPosition set to true, so that the respective position is used when we interact with the element. The returned elements are in general shallow clones of the original element, however for elements with sub-elements (e.g. LabelWithCheckbox) those should be cloned in an override of the CloneForMultipleInstances method.
Syntax:
Return Value:
A list of elements corresponding to all positions where the element was found on the screen.
Exceptions:
Exception
Condition
When the element is not found at all.
FindAllInstances<T>
Finds all instances of the element that are visible on the screen.
Syntax:
Return Value:
A list of all positions (IEngineResults) where the current element was found on the screen.
Exceptions:
Exception
Condition
When the element is not found at all.
IsOnScreen
Determines whether the element is currently shown on the screen, using the WaitFor method with a very short wait time. Note: Do not use this if you expect the element to appear after an action (e.g. as verify method of another action), only if the screen is expected to be static.
Syntax:
ScrollAndFindElement
Uses the provided IScroller (if available) to find the OnScreenElement in a scrollable area. If the element is not found at current position, scrolls to top and then down in steps.
Syntax:
Parameters:
Parameter
Description
scroller
[throwException]
[waitTime]
Return Value:
The IEngineResult of the search for the element.
Exceptions:
Exception
Condition
When the element is not found after scrolling through the complete range, and throwException is true
or not set.
SetSelectFilter
Adds the select filter to Filters or replaces any existing Select filter. Other filter types in Filters are not changed. If Filters was not yet defined, it is created by this method. Invalid or empty Select filters are ignored by this method and the Filters property is not changed.
Syntax:
Parameters:
Parameter
Description
select
ToString
Returns a string that represents this instance, usually the DisplayName. Used for logging; just use $"{this}"
.
Syntax:
WaitFor
Waits for the element to appear on screen and returns an IEngineResult. If the element is found, it will call the Initialize method to initialize potential child elements that depend on the Position found by WaitFor. By default throws an exception if the element is not found after WaitTimeInSeconds.
Syntax:
Parameters:
Parameter
Description
[throwException]
[waitTime]
Return Value:
The IEngineResult of the search for the element.
Exceptions:
Exception
Condition
When the element is not found, and throwException is true
or not set.
WaitForAppear
Shorthand notation for WaitFor(false).HasSucceeded;
Can be used as verify function without lambda operator (e.g. Buttton.Click(element.WaitForDisappear);
)
Note: This method logs, whereas WaitFor() does not log.
Syntax:
WaitForDisappear
Waits for the element to disappear from the screen. Returns false if element is still found after DisappearWaitTimeInSeconds.
Can be used as verify function without lambda operator (e.g. Buttton.Click(element.WaitForDisappear);
)
Syntax:
WaitForDisappearOrOtherElement
Waits for the element to disappear from the screen or any element from elements to appear.
This is often used as verify method of an interaction that closes a dialog or similar but can also show a warning instead.
Returns false if this
element is still found after DisappearWaitTimeInSeconds and no element from elements was found. Will return the element that was found in foundElement.
Syntax:
Parameters:
Parameter
Description
foundElement
elements
Return Value:
True, if this
element disappeared or an element from elements was found. Otherwise false.
Exceptions:
Exception
Condition
ArgumentNullException
When elements is null or an empty list.
Protected Methods
WaitForImpl
The implementation for WaitFor that performs the actual search of the element on the screen.
Syntax:
Parameters:
Parameter
Description
waitTime
imgRef
Return Value:
The IEngineResult of the search for the element.
WaitFor (ImageReference, bool, TimeSpan)
Waits for a specific imageReference of the element to appear on screen and returns an IEngineResult. This method is intended for elements like Button or Checkbox to Wait for a certain state (like inactive or checked). If imageReference is null, behaves like WaitFor(bool, TimeSpan) If the imageReference is found, it will call the Initialize method to initialize potential child elements that depend on the Position found by WaitFor. By default throws an exception if the element is not found after WaitTimeInSeconds.
Syntax:
Parameters:
Parameter
Description
imageReference
The image reference that will be used to locate the element on the screen.
[throwException]
[waitTime]
Return Value:
The IEngineResult of the search for the element.
Exceptions:
Exception
Condition
When the element is not found, and throwException is true
or not set.
Do (Action, Func<bool>)
Executes the specified interact method on the element and verifies the interaction with the verify function. Performs RetryCount retries if the verify is not successful.
Syntax:
Parameters:
Parameter
Description
interact
verify
Exceptions:
Exception
Condition
When verify returned false even after the retries.
Do (Action, Func<bool>, Action)
Executes the specified interact method on the element and verifies the interaction with the verify function. Performs RetryCount retries if the verify is not successful. Before each retry, a recovery action is executed.
Syntax:
Parameters:
Parameter
Description
interact
verify
recovery
Exceptions:
Exception
Condition
When verify returned false even after the retries.
Initialize
Initializes potential child controls on this Element. This method is called when WaitFor() did find the element. Has no implementation on OnScreenElement.
Syntax:
Last updated
Was this helpful?