Manage Mobile Test Object
Estimated reading time: 2 minutes
Create a Test Object
Select File > New > Test Object from the main menu. The New Test Object dialog will be displayed.
Provide the name for the new test object, then click OK button. A new test object is created under the Object Repository of Katalon Studio.
Add an object property
There cannot be two properties with the same name in the same test object.
- In the Object's Properties panel, click Add.
- The Add property dialog will be displayed.
- Name: The name of the object property. The drop-down list provides some common options for your selection (XPath, CSS, class, id, title) or you can enter manually.
- Match condition: The condition is used for searching for the "actual" object in the AUT when executing automation tests.
- Value: The value that completes a match condition.
- The new property is added to the properties list as specified. You can also edit the properties' values here.
Properties used for detecting an object
Katalon Studio selects Attributes by default to locate mobile test objects. A test object is typically built up by a number of properties. During test execution, Katalon Studio bases on such information to detect an object. Using Detect object by field, you can determine the properties to be utilized for recognizing objects.
In the following example, Katalon Studio tries to find any object on AUT with text tp satisfy the defined criteria during execution.
Validate Test Object on AUT
You can add test objects to Mobile Object Spy dialog to verify detection in the application under test. Refer to Spy Mobile Utility for details regarding how to validate captured objects against the application under test.
To add an object to Mobile Object Spy, simply right-click on the item to open its context menu and select the option.
Test Objects in Scripting View
The test case Script View allows you to programmatically define and handle Test Objects as needed. The following is a simple sample demonstrating how to do that:
- Refer to existing objects using the findTestObject() method:
// Find an object which was defined already in Object Repository myPredefinedObject = findTestObject('android.widget.TextView - App')
- Create a new object programmatically using TestObject class:
// Create a new object programmatically myNewObject = new TestObject("TestObjectID")
- Add the property to an object using addProperty() method:
// Add property to Test Object, a property is defined by: // property name, // condition type, // property value, // a boolean value to indicate if the property will be used to identify the object during execution myNewObject.addProperty("class", ConditionType.EQUALS, "android.widget.TextView", true)