SlObject Method

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

Use this method to obtain access to the specified object of a Silverlight application. The resulting object contains methods, fields and properties defined in application code, as well as methods, properties and actions provided by TestComplete.

Declaration

TestObj.SlObject(Name)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Name [in]    Required    String    
Result Object

TestObj.SlObject(ClassName, Text)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ClassName [in]    Required    String    
Text [in]    Required    String    
Result Object

TestObj.SlObject(ClassName, Text, Index)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
ClassName [in]    Required    String    
Text [in]    Required    String    
Index [in]    Required    Integer    
Result Object

Applies To

Web and XUL objects and all Silverlight application objects.

View Mode

To view this method in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Parameters

The method has the following parameters:

Name

The name of the desired Silverlight object as it is specified in the tested application’s source code (the string that is returned by the SlObjectName property).

ClassName

The object’s class name that is specified by the application’s code. This value is returned by the SlClassName property of the object. You can use wildcards (* and ?) in this parameter.

Text

The text of the object (the object’s caption, in most cases). This value is returned by the SlObjectText property. You can use wildcards (* and ?) in this parameter.

Index

The object’s index among sibling objects of the same type. This value is returned by the SlObjectIndex property.

The Index parameter is used only if an object contains two or more child objects that have the same class name and caption. It is used to distinguish these objects from each other. The first found object has an index of 0, the second -  1 and so on.

If there is only one child object with the specified class name and caption, index should not be specified. To decide whether the index should be used, explore your application in the Object Browser panel and use the naming format that is used by the panel.

Result Value

The SlObject method returns an object that provides access to an object located in a Silverlight application. If TestComplete cannot access the specified object (for example, this object does not exist), the method will return an empty stub object and post an error message to the test log. To determine whether SlObject returns a valid object, use the Exists property of the resultant object. If this property returns False, then the returned object is a stub object and the call to SlObject was not successful.

Remarks

The returned object contains methods, fields and properties defined in the application code, as well as methods, properties and actions provided by TestComplete. The returned object may hold two or more methods or properties having the same name. When you call such a method or property, a naming conflict will occur. To avoid it and to specify which method or property is to be called, use the NativeSlObject namespace.

The SlObject method is available only if the Silverlight Application Support and Web Testing plugins are installed. Otherwise, the method is absent in the method list of the TestObj object.

To obtain the class name, text and index used by the second or third implementation of the SlObject method, use the SlClassName, SlObjectText and SlObjectIndex properties.

Example

To view an example that demonstrates how to use the SlObject method, see Addressing Objects of In-Browser Silverlight Applications.

See Also

Addressing Objects of In-Browser Silverlight Applications
About Open Applications
Object Browser Naming Notation
Using Namespaces
SlClassName Property
SlObjectName Property
SlObjectText Property
SlObjectIndex Property
WaitSlObject Method

Highlight search results