Identifying Silverlight Objects

Applies to TestLeft 15.10, last modified on November 16, 2021
Search Patterns

To search for objects in Silverlight applications, you use search patterns of the SlPattern type.

.NET: The pattern belongs to the SmartBear.TestLeft.TestObjects.Silverlight namespace.

Java: The pattern belongs to the com.smartbear.testleft.testobjects package.

This pattern uses the following properties:

Property Type Description
Enabled Boolean Specifies whether the object is enabled or disabled. Disabled objects are usually shown grayed out.
SlFullClassName String The object’s full class name including the namespace name. For example, System.Windows.Controls.RadioButton.
SlObjectIndex Integer The object’s index (0-based) among sibling objects with the same class name.
SlObjectName String The object name specified by the developers in the application’s source code.
SlObjectText String The object text. Usually, this is the value of the object’s Text or Content native property.
Visible Boolean Specifies whether the object is visible in the application. Objects that are out of screen bounds or overlapped by other objects are still considered visible.

You can use any combination of these properties in your Silverlight search patterns.

Example

C#

ICheckBox checkBox = webpage.Find<IWindow>(new WebElementPattern()
{
   ObjectType = "Object",
   idStr = "MySilverlightApp"
}, 5).Find<ITabControl>(new SlPattern()
{
   SlObjectName = "SamplesTab"
}).Find<ICheckBox>(new SlPattern()
{
   SlFullClassName = "System.Windows.Controls.CheckBox",
   SlObjectText = "IsReadOnly"
});

Visual Basic .NET

Dim checkBox As ICheckBox = webpage.Find(Of IWindow)(New WebElementPattern() With {
   .ObjectType = "Object",
   .idStr = "MySilverlightApp"
}, 5).Find(Of ITabControl)(New SlPattern() With {
   .SlObjectName = "SamplesTab"
}).Find(Of ICheckBox)(New SlPattern() With {
   .SlFullClassName = "System.Windows.Controls.CheckBox",
   .SlObjectText = "IsReadOnly"
})

Java

CheckBox checkBox = webpage.find(Window.class, new WebElementPattern() {{
   ObjectType = "Object";
   idStr = "MySilverlightApp";
}}, 5).find(TabControl.class, new SlPattern() {{
   SlObjectName = "SamplesTab";
}}).find(CheckBox.class, new SlPattern() {{
   SlFullClassName = "System.Windows.Controls.CheckBox";
   SlObjectText = "IsReadOnly";
}});

Custom Properties

You can also specify custom properties by using the .add("propertyname", value) method of the pattern object. See Using Custom Properties in Search Patterns.

See Also

Understanding Object Identification
Preparing Silverlight Applications for Testing

Highlight search results