XFObject Method (Xamarin.Forms Objects)

Applies to TestComplete 14.70, last modified on April 22, 2021

Description

Use this method to get a scripting interface to an object of a tested Xamarin.Forms application. The resulting object contains properties and methods defined in the application's source code and methods and properties provided by TestComplete.

Declaration

TestObj.XFObject(ControlName)

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

TestObj.XFObject(ClassNameControlText)

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    
ControlText [in]    Required    String    
Result Object

TestObj.XFObject(ClassNameControlTextIndex)

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    
ControlText [in]    Required    String    
Index [in]    Required    Integer    
Result Object

Applies To

The method is applied to the following object:

A process object corresponding to the tested Xamarin.Forms application, all Xamarin.Forms test objects.

View Mode

This method is not displayed in the Object Browser panel.

Parameters

The method has the following parameters:

ControlName

The name of the object as it is specified by the developers in the application’s source code. This is the value of the object’s XFControlName property.

If the name is unavailable (for example, the application developers did not specify it), use the second implementation of the method to address the desired object.

ClassName

The object's class name as it is specified in the application's source code. Specify a short class name, for instance, Button, rather than Xamarin.Forms.Button. You can use wildcards (* and ?).

ControlText

The text of the onscreen object. You can use wildcards (* and ?).

Index

The index of the object among its sibling objects with the same class name and text.

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 1, the second -  2 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 object that provides a scripting interface to an object in the tested Xamarin.Forms application. If TestComplete cannot access the specified object (for example, the object does not exist), the method will post an error to the test log and will return an empty stub object. To determine whether the object is valid, use its Exists property. If the method returns a valid object, its Exists property will return True. Otherwise, it will return False.

Remarks

If you use only one parameter, TestComplete uses the first implementation of the XFObject method and the first parameter as the object name. If you use two or three parameters, TestComplete uses the second or third implementation respectively.

The object returned by the XFObject method contains methods 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 and properties that have the same name. If you call such a method or property, a naming conflict will occur. To avoid this and to specify which method or property is to be called, use the NativeXFObject namespace.

The XFObject method is available for objects only in Xamarin.Forms applications, and only if you have an active license for the TestComplete Mobile module and the Android Support and iOS Support plugins are enabled in TestComplete.

Example

To view an example that demonstrates how to use the XFObject method, see Addressing Objects in Xamarin.Forms Applications.

See Also

WaitXFObject Method
About Xamarin.Forms Application Testing
Addressing Objects in Xamarin.Forms Applications
Object Browser Naming Notation
Using Namespaces
About Open Applications

Highlight search results