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 Object Repository of Katalon Studio.
Add an object property
There cannot be two properties with the same name existed in the same test object.
- In the Test Object Editor, click on the Add command.
The Add property dialog is displayed.
Field Description Name The name of the object property. The dropdownlist provide some common option for your selection (xpath, css, class, id, title) or you can enter manually if wanted. Match condition The condition which will be used to search for the “actual” object in the application under test when executing automation tests. Value The value which will be used to search for the “actual” object in the application under test when executing automation tests.
Click OK when you finish with configuring.
- The new property is added to properties list as specified.
Manage parent object
Nowadays, there are many web applications which render elements in an iframe. Therefore, you have to tell your script how to traverse a website’s iframes and select the correct iframe where the text and its object are present. In order to do so, you have to use 'Switch To Frame' keyword before interacting with the elements.
Katalon Studio does support the ability to define parent iframe object within test object view, so you just only need to select the parent iframe and the execution will automatically switches to that iframe.
Properties used for detecting object
A test object is typically built up by a number of properties. During test execution, Katalon Studio bases on such information in order to detect an object. Using Detect object by field, you can determine the properties to be utilized for recognizing objects.
In the following example, if during execution, Katalon Studio could find any object on AUT with both href and class that satisfy the defined criteria, then that object will be recognized as the a_Free Download object.
Validate Test Object on AUT
You can add test objects to Web Object Spy dialog to verify whether they are still correctly detected in the application under test. Refer to Web Object Spy for details regarding how to validate captured objects against the application under test.
- To add an object to Web Object Spy, simply right click on the item to open its context menu and select the option.
Parameterizing Test Object
Katalon Studio provides user with the ability to handle dynamic objects (Objects that have some particular properties change due to certain business rules). By supporting a way to parameterize test objects, users can leverage this approach to control objects dynamically. The example below describes basic steps to do this:
- Open your Test Case in Manual View and double click on the object that you want to parameterize its properties.
- The Test Object Input dialog is displayed. Expand the Object Parameters section and declare your expected dynamic properties. These properties will be used to identify the test object during execution. For this example, Katalon Studio will make use of the 'id' property with its value when finding the 'txt_UserName' object.
Once the property is declared, you can switch to the Script View of the Test Case and adjust how the value of the property to be perceived. (Typically, users will want to pass property value as variables or make reference to datafiles according to their situation).
The general syntax to find a test object using a dynamic property is as following:
+ One dynamic property
+ Two dynamic properties
+ Using variable for value of dynamic property
+ Using variable for value in test object:
Test Objects in Scripting View
The Script View of Test Case allows you to programmatically define and handle Test Objects as needed. Following is a simple sample showing you how to do that:
Refer to existing objects using the findTestObject() method
Create a new object programmatically using TestObject class
Add property to an object using addProperty() method
The following API docs may prove useful when working with test objects:
|Test Object||addProperty(String name, ConditionType condition, String value)||Add a new property to the test object|
|setProperties(List<TestObjectProperty> properties)||Set the properties of the test object|
|getObjectId()||Get object ID.|
|findPropertyValue(String name, boolean caseSensitive)||Find the value of a property using the property name|