Class
WpfWindow

Actions for automating WPF window.

Definition

Namespace:ArtOfTest.WebAii.Wpf

Assembly:ArtOfTest.WebAii.dll

Syntax:

cs-api-definition
public class WpfWindow : VisualTreeHost, IApplication, IAutomationHost, ISupportSearchHost, IAnnotationHost, IDisposable

Inheritance: objectVisualTreeHostWpfWindow

Implements: IAnnotationHostIApplicationIAutomationHostIDisposableISupportSearchHost

Inherited Members VisualTreeHost.GetHostRoot()VisualTreeHost.LocateAllInHost(string[])VisualTreeHost.UpdateInterHostLinks()VisualTreeHost.FixAnnotationArea(Rectangle)VisualTreeHost.OwnerAppVisualTreeHost.VisualTreeVisualTreeHost.StateHashCodeVisualTreeHost.ShouldDisplayAnnotation

Constructors

WpfWindow(IntPtr)

Create new instance of WpfWindow class.

Declaration

cs-api-definition
protected WpfWindow(IntPtr hwnd)

Parameters

hwnd

IntPtr

Properties

Annotator

Declaration

cs-api-definition
public override Annotator Annotator { get; }

Property Value

Annotator

Overrides VisualTreeHost.Annotator

Implements IAnnotationHost.Annotator

Application

The WPF application that the current window is part of.

Declaration

cs-api-definition
public WpfApplication Application { get; }

Property Value

WpfApplication

Bounds

Gets the rectangular bounds of this app.

Declaration

cs-api-definition
public Rectangle Bounds { get; }

Property Value

Rectangle

Implements IApplication.Bounds

ContentWindow

Declaration

cs-api-definition
public override Window ContentWindow { get; }

Property Value

Window

Overrides VisualTreeHost.ContentWindow

Implements IAnnotationHost.ContentWindow

Desktop

Gets the Desktop object for this app.

Declaration

cs-api-definition
public Desktop Desktop { get; }

Property Value

Desktop

Implements IApplication.Desktop

EnableValidateMouseLocation

Enables mouse location validation.

Declaration

cs-api-definition
public bool EnableValidateMouseLocation { get; set; }

Property Value

bool

Implements IApplication.EnableValidateMouseLocation

Find

Actions for finding visual elements.

Declaration

cs-api-definition
public virtual VisualFind Find { get; }

Property Value

VisualFind

Implements IApplication.Find

FriendlyName

Returns a friendly name for this host

Declaration

cs-api-definition
public override string FriendlyName { get; }

Property Value

string

Overrides VisualTreeHost.FriendlyName

Implements IAutomationHost.FriendlyName

IsConnected

Indicates whether current object is connected to window under test.

Declaration

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

Property Value

bool

Implements IApplication.IsConnected

IsRecordingHost

Indicates whether a recorder is attached.

Declaration

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

Property Value

bool

Implements IApplication.IsRecordingHost

ManagedProxy

Gets the ManagedProxy for this app.

Declaration

cs-api-definition
public virtual ICommunicationProxy ManagedProxy { get; }

Property Value

ICommunicationProxy

Implements IApplication.ManagedProxy

Manager

Declaration

cs-api-definition
public override Manager Manager { get; }

Property Value

Manager

Overrides VisualTreeHost.Manager

Implements IAnnotationHost.Manager

Popups

Declaration

cs-api-definition
protected HashSet<IntPtr> Popups { get; }

Property Value

HashSet<IntPtr>

TechnologyType

VisualTreeHosts are only used for Silverlight

Declaration

cs-api-definition
public override TechnologyType TechnologyType { get; }

Property Value

TechnologyType

Overrides VisualTreeHost.TechnologyType

Implements IAutomationHost.TechnologyType

UniqueId

A unique identifier that identifies this plugin instance. This id is updated only when the plug-in is reloaded on a postback or a browser refresh.

Declaration

cs-api-definition
public override string UniqueId { get; }

Property Value

string

Overrides VisualTreeHost.UniqueId

Implements IAutomationHost.UniqueId

Window

Declaration

cs-api-definition
public override Window Window { get; }

Property Value

Window

Overrides VisualTreeHost.Window

Implements IAnnotationHost.Window

Methods

AddCustomAssembly(string, string)

Register assembly to be loaded in app under test. Actual loading happens when new window is created or when InitializeCustomWpfTypes() is called.

Declaration

cs-api-definition
public static void AddCustomAssembly(string assemblyName, string assemblyPath)

Parameters

assemblyName

string

Assembly name.

assemblyPath

string

Path to assembly.

AddCustomAssemblyFolder(string)

Register folder containing asseblies to be loaded in app under test. Actual loading happens when new window is created or when InitializeCustomWpfTypes() is called. Note that .net core applications will load only assemblies from 'netcore' subfolder.

Declaration

cs-api-definition
public static void AddCustomAssemblyFolder(string assemblyFolder)

Parameters

assemblyFolder

string

Path of the folder.

Capture()

Return a bitmap of the host

Declaration

cs-api-definition
public override Bitmap Capture()

Returns

Bitmap

Overrides VisualTreeHost.Capture()

Implements IAutomationHost.Capture()

Capture(FrameworkElement)

Capture the image of an element.

Declaration

cs-api-definition
public Bitmap Capture(FrameworkElement element)

Parameters

element

FrameworkElement

The element to interact with.

Returns

Bitmap

The element image/

Implements IApplication.Capture(FrameworkElement)

ClearCustomAsseblies()

Clear all assemblies registered by ClearCustomAsseblies().

Declaration

cs-api-definition
public static void ClearCustomAsseblies()

ClearCustomAssemblyFolders()

Clear all assembly folders registered by AddCustomAssemblyFolder(string).

Declaration

cs-api-definition
public static void ClearCustomAssemblyFolders()

DetachFromWindowEvents()

Stop listening window events.

Declaration

cs-api-definition
protected void DetachFromWindowEvents()

Dispose()

Clean up resources.

Declaration

cs-api-definition
public void Dispose()

Implements IDisposable.Dispose()

ElementFromPoint(int, int)

Get the framework element that is located under specific point.

Declaration

cs-api-definition
public virtual FrameworkElement ElementFromPoint(int x, int y)

Parameters

x

int

The point X coordinate.

y

int

The point Y coordinate.

Returns

FrameworkElement

The framework element that is located under specific point.

Implements IApplication.ElementFromPoint(int, int)

EnsureElementClickable(FrameworkElement)

Ensure that an element is in the visible part of the window.

Declaration

cs-api-definition
public void EnsureElementClickable(FrameworkElement element)

Parameters

element

FrameworkElement

The element to interact with.

Implements IApplication.EnsureElementClickable(FrameworkElement)

EnsureStateIsCurrent()

Will force the VisualTree to Refresh. Identical to VisualTree.Refresh().

Declaration

cs-api-definition
public override void EnsureStateIsCurrent()

Overrides VisualTreeHost.EnsureStateIsCurrent()

Implements IAutomationHost.EnsureStateIsCurrent()

GetChildHosts()

Get all contained hosts.

Declaration

cs-api-definition
public override IAutomationHost[] GetChildHosts()

Returns

IAutomationHost[]

Contained Hosts

Overrides VisualTreeHost.GetChildHosts()

Implements IAutomationHost.GetChildHosts()

GetScreenRectangle(FrameworkElement)

Get the bounding rectangle of an element in screen coordinates.

Declaration

cs-api-definition
public virtual Rectangle GetScreenRectangle(FrameworkElement element)

Parameters

element

FrameworkElement

The element to interact with.

Returns

Rectangle

The element bounding rectangle.

Implements IApplication.GetScreenRectangle(FrameworkElement)

GetToolTipText(FrameworkElement)

Get the tooltip text of an element.

Declaration

cs-api-definition
public virtual string GetToolTipText(FrameworkElement element)

Parameters

element

FrameworkElement

The element to interact with.

Returns

string

The element tooltip text.

Implements IApplication.GetToolTipText(FrameworkElement)

GetWindowRectangle()

Gets the rectangle of window containing this host

Declaration

cs-api-definition
public override Rectangle GetWindowRectangle()

Returns

Rectangle

Overrides VisualTreeHost.GetWindowRectangle()

Implements IAutomationHost.GetWindowRectangle()

InitializeCustomWpfTypes()

Ask app under test to load assemblies with custom wpf types.

Declaration

cs-api-definition
public void InitializeCustomWpfTypes()

IsActiveWindow()

Declaration

cs-api-definition
protected virtual bool IsActiveWindow()

Returns

bool

LocateInHost(string[])

Locate an element in this host or any of the children of this host using an expression.

Declaration

cs-api-definition
public override ITargetElement LocateInHost(string[] expression)

Parameters

expression

string[]

Returns

ITargetElement

Overrides VisualTreeHost.LocateInHost(string[])

Implements ISupportSearchHost.LocateInHost(string[])

OnRecordingWindowClosed()

Declaration

cs-api-definition
protected virtual void OnRecordingWindowClosed()

PopulateVisualTree()

Populate visual tree using the latest state from window under test.

Declaration

cs-api-definition
public virtual VisualTree PopulateVisualTree()

Returns

VisualTree

Newly generated visual tree.

Implements IApplication.PopulateVisualTree()

RefreshVisualTrees()

Refreshes the main visual tree for the application as well as any open Popup visual trees.

Declaration

cs-api-definition
public void RefreshVisualTrees()

Implements IApplication.RefreshVisualTrees()

ResizeContainer(int, int, int, int)

Resize window under test.

Declaration

cs-api-definition
public void ResizeContainer(int x, int y, int width, int height)

Parameters

x

int

The window X position to be set.

y

int

The window Y position to be set.

width

int

The window width to be set.

height

int

The window height to be set.

Implements IApplication.ResizeContainer(int, int, int, int)

SetWindowFocus()

Makes the window containing this host active

Declaration

cs-api-definition
public override bool SetWindowFocus()

Returns

bool

Whether we successfully set the window to active

Overrides VisualTreeHost.SetWindowFocus()

Implements IAutomationHost.SetWindowFocus()

ValidateMouseLocation(Point)

Validate the location of the mouse.

Declaration

cs-api-definition
public override void ValidateMouseLocation(Point point)

Parameters

point

Point

Overrides VisualTreeHost.ValidateMouseLocation(Point)

Implements IAutomationHost.ValidateMouseLocation(Point)

~WpfWindow()

Finalizer.

Declaration

cs-api-definition
protected ~WpfWindow()

Events

WindowClosed

This event is triggered when the wrapped window closes

Declaration

cs-api-definition
public event EventHandler WindowClosed

Event Value

EventHandler