The SilverlightApp Object

The SilverlightApp object is the main object you interact with when automating a Silverlight plug-in. It is the entry point into the Silverlight plug-in. Below are the properties offered by the SilverlightApp object:

 

Property

Description

Bounds Returns a Rectangle object that is the actual screen coordinates of this Silverlight plug-in (which may be different from the rectangle of the Silverlight application).
Content Exposes the properties found in plugin.content as documented in MSDN. (e.g. ActualHeight, ActualWidth, FullScreen).

Note: All properties are read-only.
Desktop Get the Desktop object which may be used for real Keyboard/Mouse automation.
EnableValidateMouseLocation Gets / Sets whether to validate mouse click locations before allowing user interaction automation.
Find Exposes a Find object used to search the VisualTree for FrameworkElements. This property is a shortcut to the VisualTree.Find object.
Host Returns an HtmlControl object that represents the actual html tag that the plug-in object tag is contained in. Typically this is a Div tag if you are using Visual Studio's Silverlight designer.
IsLoaded Indicates whether or not this plug-in is currently loaded.
OwnerBrowser Gets the  browser owning this Silverlight application.
Plugin Returns an HtmlControl object that represents the actual HTML object tag of the plug-in.
Settings Exposes the properties found in plugin.settings as documented in MSDN. (e.g. Background, EnableHtmlAccess, EnableFramerateCounter, etc).

Note: All properties are read-only.
FindName/FindName<T> A shortcut to the Find.ByName & Find.ByName<> methods used to find an element using its XAML set name.
VisualTree The entire VisualTree of this application. The VisualTree can be navigated up and down and the root element can be accessed using VisualTree.Root. The elements accessed from the VisualTree are FrameworkElement objects.

The VisualTree

The VisualTree object exposed by the SilverlightApp is a hierarchal representation of the VisualTree of the Silverlight application at a given point in time. If your Silverlight application changes, you can always refresh this tree by calling VisualTree. Refresh(). The VisualTree also exposes the VisualTree.Root property which is a FrameworkElement that represents the root element of the VisualTree of the application.

Note: To help eliminate any synchronization issues between the VisualTree available to the test client and the application running in the browser, every time the Find object attempts to find an element in the tree, it will always refresh before starting the search to ensure that the frameworks copy of the tree is in-sync with the application.

SilverlightApp Methods

The SilverlightApp object also offers the following methods you can use in your automation:

 

Method

Description

ClearHighlight Clear any highlighting on the Silverlight surface.
Disconnect Disconnect automation from this Silverlight plug-in.
ElementsFromPoint Gets a list of FrameworkElements under the specified point in the application.
EnsureStateIsCurrent Will force the VisualTree to Refresh. Identical to VisualTree.Refresh().
FindName/FindName<T> A shortcut to the Find.ByName & Find.ByName<> methods used to find an element using its XAML name.