ClassDesktopElement
Provides functionality for automating a desktop element.
Definition
Namespace:ArtOfTest.WebAii.DesktopAutomation
Assembly:ArtOfTest.WebAii.dll
Syntax:
public class DesktopElement : ITargetElement
Inheritance: objectDesktopElement
Implements:
Fields
find
Find object. Use to search desktop elements by specific properties.
nativeElement
The underlying native element.
Declaration
protected IUIAutomationElement nativeElement
Field Value
IUIAutomationElement
Properties
AutomationId
Element automation.
ClassName
Element class name.
ControlType
Element control type.
ControlTypeName
Get control type as human readable string.
Declaration
public string ControlTypeName { get; }
Property Value
Control type name.
Find
Find object. Use to search desktop elements by specific properties.
FrameworkId
Element UI framework.
HasKeyboardFocus
Indicates whether element has keyboard focus.
HelpText
Element help text.
Host
A reference to the host of the element.
IsEnabled
Indicates whether element is enabled or not.
IsKeyboardFocusable
Indicates whether element can receive keyboard focus.
IsOffscreen
Indicates whether element is off screen.
LocalizedControlType
Element localized control type as string.
Declaration
public virtual string LocalizedControlType { get; }
Property Value
Name
Element name.
ProcessId
Id of element owner process.
Methods
As<T>()
Create desktop control from current desktop element.
Declaration
public T As<T>() where T : DesktopControl
Returns
T
New instance of T if element is specified control type.
Capture()
Capture element image.
CastIncludingAncestors<T>(int)
Create desktop control from current desktop element or any matching parent.
Declaration
public T CastIncludingAncestors<T>(int depth = 5) where T : DesktopControl
Parameters
depth
Returns
T
New instance of T if element or any parent is specified control type.
Exists()
Verify underlying element still exists.
Declaration
public bool Exists()
Returns
True if element exists, otherwise false.
FromDesktopRoot()
Create new instance of DesktopElement that points to desktop root component.
FromScreenCoordinates(int, int)
Create new instance of DesktopElement that points to UI component located on specific coordinates.
Declaration
public static DesktopElement FromScreenCoordinates(int x, int y)
Parameters
x
y
Returns
FromWindowHandle(IntPtr)
Create new instance of DesktopElement that points to window with specific handle.
Declaration
public static DesktopElement FromWindowHandle(IntPtr handle)
Parameters
handle
Returns
GetChildren()
Enumerate element children.
Declaration
public virtual IEnumerable<DesktopElement> GetChildren()
Returns
IEnumerable containing element children.
GetNextSibling()
Get element next sibling.
Declaration
public virtual DesktopElement GetNextSibling()
Returns
Next sibling as desktop element.
GetParent()
Get element parent.
Declaration
public virtual DesktopElement GetParent()
Returns
Element parent as desktop element.
GetPreviousSibling()
Get element previous sibling.
Declaration
public virtual DesktopElement GetPreviousSibling()
Returns
Previous sibling as desktop element.
GetScreenRectangle()
Get element bounds rectangle.
Declaration
public Rectangle GetScreenRectangle()
Returns
Rectangle object using screen coordinates.
IsVisible()
Check whether element is visible or not.
Declaration
public virtual bool IsVisible()
Returns
True if element is visible, otherwise false.
PointsToSameAs(DesktopElement)
Determine if two desktop element instances point to same UI component.
Declaration
public bool PointsToSameAs(DesktopElement element)
Parameters
element
The element to compare against.
Returns
True if both desktop elements point to same UI component, otherwise false.
ScrollToVisible(ScrollOption)
Scroll element to owner application visible area if possible.
Declaration
public void ScrollToVisible(ScrollOption scrollOption)
Parameters
scrollOption
Determines where element should be located once scrolling is complete.
WaitFor(Func<bool>, int, int)
Wait for predicate to become true or timeout to occur.
Declaration
public bool WaitFor(Func<bool> predicate, int delay = 500, int timeout = 2500)
Parameters
predicate
Predicate to wait for.
delay
Delay in milliseconds before invoking the predicate.
timeout
Operation timeout in milliseconds.
Returns
True if predicate was true within timeout interval, otherwise false.
WaitForNoMotion(int, int)
Wait for element to be stationary.