Class
DesktopElement

Provides functionality for automating a desktop element.

Definition

Namespace:ArtOfTest.WebAii.DesktopAutomation

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class DesktopElement : ITargetElement

Inheritance: objectDesktopElement

Implements: ITargetElement

Fields

find

Find object. Use to search desktop elements by specific properties.

Declaration

cs-api-definition
protected DesktopFind find

Field Value

DesktopFind

nativeElement

The underlying native element.

Declaration

cs-api-definition
protected IUIAutomationElement nativeElement

Field Value

IUIAutomationElement

Properties

AutomationId

Element automation.

Declaration

cs-api-definition
public virtual string AutomationId { get; }

Property Value

string

ClassName

Element class name.

Declaration

cs-api-definition
public virtual string ClassName { get; }

Property Value

string

ControlType

Element control type.

Declaration

cs-api-definition
public virtual int ControlType { get; }

Property Value

int

ControlTypeName

Get control type as human readable string.

Declaration

cs-api-definition
public string ControlTypeName { get; }

Property Value

string

Control type name.

Find

Find object. Use to search desktop elements by specific properties.

Declaration

cs-api-definition
public DesktopFind Find { get; }

Property Value

DesktopFind

FrameworkId

Element UI framework.

Declaration

cs-api-definition
public virtual string FrameworkId { get; }

Property Value

string

HasKeyboardFocus

Indicates whether element has keyboard focus.

Declaration

cs-api-definition
public virtual bool HasKeyboardFocus { get; }

Property Value

bool

HelpText

Element help text.

Declaration

cs-api-definition
public virtual string HelpText { get; }

Property Value

string

Host

A reference to the host of the element.

Declaration

cs-api-definition
public IAutomationHost Host { get; }

Property Value

IAutomationHost

IsEnabled

Indicates whether element is enabled or not.

Declaration

cs-api-definition
public virtual bool IsEnabled { get; }

Property Value

bool

IsKeyboardFocusable

Indicates whether element can receive keyboard focus.

Declaration

cs-api-definition
public virtual bool IsKeyboardFocusable { get; }

Property Value

bool

IsOffscreen

Indicates whether element is off screen.

Declaration

cs-api-definition
public virtual bool IsOffscreen { get; }

Property Value

bool

LocalizedControlType

Element localized control type as string.

Declaration

cs-api-definition
public virtual string LocalizedControlType { get; }

Property Value

string

Name

Element name.

Declaration

cs-api-definition
public virtual string Name { get; }

Property Value

string

ProcessId

Id of element owner process.

Declaration

cs-api-definition
public virtual int ProcessId { get; }

Property Value

int

RuntimeId

Element runtime id. Note that runtime id may change once app is restarted.

Declaration

cs-api-definition
public virtual string RuntimeId { get; }

Property Value

string

Methods

As<T>()

Create desktop control from current desktop element.

Declaration

cs-api-definition
public T As<T>() where T : DesktopControl

Returns

T

New instance of T if element is specified control type.

Capture()

Capture element image.

Declaration

cs-api-definition
public Bitmap Capture()

Returns

Bitmap

Bitmap image.

CastIncludingAncestors<T>(int)

Create desktop control from current desktop element or any matching parent.

Declaration

cs-api-definition
public T CastIncludingAncestors<T>(int depth = 5) where T : DesktopControl

Parameters

depth

int

Returns

T

New instance of T if element or any parent is specified control type.

Exists()

Verify underlying element still exists.

Declaration

cs-api-definition
public bool Exists()

Returns

bool

True if element exists, otherwise false.

FromDesktopRoot()

Create new instance of DesktopElement that points to desktop root component.

Declaration

cs-api-definition
public static DesktopElement FromDesktopRoot()

Returns

DesktopElement

FromScreenCoordinates(int, int)

Create new instance of DesktopElement that points to UI component located on specific coordinates.

Declaration

cs-api-definition
public static DesktopElement FromScreenCoordinates(int x, int y)

Parameters

x

int

y

int

Returns

DesktopElement

FromWindowHandle(IntPtr)

Create new instance of DesktopElement that points to window with specific handle.

Declaration

cs-api-definition
public static DesktopElement FromWindowHandle(IntPtr handle)

Parameters

handle

IntPtr

Returns

DesktopElement

GetChildren()

Enumerate element children.

Declaration

cs-api-definition
public virtual IEnumerable<DesktopElement> GetChildren()

Returns

IEnumerable<DesktopElement>

IEnumerable containing element children.

GetNextSibling()

Get element next sibling.

Declaration

cs-api-definition
public virtual DesktopElement GetNextSibling()

Returns

DesktopElement

Next sibling as desktop element.

GetParent()

Get element parent.

Declaration

cs-api-definition
public virtual DesktopElement GetParent()

Returns

DesktopElement

Element parent as desktop element.

GetPreviousSibling()

Get element previous sibling.

Declaration

cs-api-definition
public virtual DesktopElement GetPreviousSibling()

Returns

DesktopElement

Previous sibling as desktop element.

GetScreenRectangle()

Get element bounds rectangle.

Declaration

cs-api-definition
public Rectangle GetScreenRectangle()

Returns

Rectangle

Rectangle object using screen coordinates.

IsVisible()

Check whether element is visible or not.

Declaration

cs-api-definition
public virtual bool IsVisible()

Returns

bool

True if element is visible, otherwise false.

PointsToSameAs(DesktopElement)

Determine if two desktop element instances point to same UI component.

Declaration

cs-api-definition
public bool PointsToSameAs(DesktopElement element)

Parameters

element

DesktopElement

The element to compare against.

Returns

bool

True if both desktop elements point to same UI component, otherwise false.

ScrollToVisible(ScrollOption)

Scroll element to owner application visible area if possible.

Declaration

cs-api-definition
public void ScrollToVisible(ScrollOption scrollOption)

Parameters

scrollOption

ScrollOption

Determines where element should be located once scrolling is complete.

SetFocus()

Set focus to current element.

Declaration

cs-api-definition
public void SetFocus()

WaitFor(Func<bool>, int, int)

Wait for predicate to become true or timeout to occur.

Declaration

cs-api-definition
public bool WaitFor(Func<bool> predicate, int delay = 500, int timeout = 2500)

Parameters

predicate

Func<bool>

Predicate to wait for.

delay

int

Delay in milliseconds before invoking the predicate.

timeout

int

Operation timeout in milliseconds.

Returns

bool

True if predicate was true within timeout interval, otherwise false.

WaitForNoMotion(int, int)

Wait for element to be stationary.

Declaration

cs-api-definition
public bool WaitForNoMotion(int checkInterval = 500, int timeout = 2500)

Parameters

checkInterval

int

Check interval in ms.

timeout

int

Timeout in ms.

Returns

bool

True if element is stationary, otherwise false.