Skip to main content

Parameterize Mobile Test Object Properties in Katalon Studio

  • Parameterizing Mobile Test Object Properties is only available with the Attributes Selection Method.

The benefits of parameterizing mobile test objects are similar to those of parameterizing web test objects. Refer to this document for further details.

Usage Example

Below is an example of how to parameterize test objects in Mobile testing. Open a sample project of Mobile testing on Android devices by accessing File> New Sample Project> Sample Android Mobile Tests Project.

Navigate to Object Repository/Application/android.widget.TextView - App in Tests Explorer, open the test object view of android.widget.TextView - App whose property will be parameterized.

In this example, we want to find a test object that has //*[(text() = 'demokatalon' or . = 'demokatalon')] as its selector. Here are the steps to apply this feature:

Step 1: Parameterize the test object's dynamic property

Create a property with its value as a variable having this syntax: ${Variable_name}. For this example, in the Object's Properties panel, add an object's property with:

  • Name: text
  • Value: ${text}
Its selected locator is generated as
//*[(text() =
'${text}' or . = '${text}')]
and identified at runtime with passing data.

Step 2: Use the parameterized test object in a test case

  • In Manual View

    In the Verify Correct Alarm Message test case, double-click the test object that contains the parameterized property, which is android.widget.TextView - App. The Test Object Input dialog is displayed.

    In the Variables panel, add a new variable with the following properties:

    • Param Type: the variable type (The default type is String).
    • Param: the variable name of the property created in step 1.
    • Value Type: the type of the variable's value.
    • Value: a specific value of that variable.

  • In Script View

    You can also switch to the Scripting Mode of the current Test Case to adjust the property's value at any time. The predefined variable is automatically mapped when you select a mobile object from manual mode, so you don't need to define them again manually.

Step 3: Call the findTestObject method within a keyword

In this example, the tap keyword is performed on the object with the text value that we have just specified.

Mobile.tap(findTestObject('Application/android.widget.TextView -
App', [('text') : 'demokatalon']), 10)

Escaping special characters

To use a special character like $ or \ as a regular one in any place that uses parameterized test objects, prepend it with a backslash: \ (the so-called escape character).

"productName": ${GlobalVariable.productName},
"unit": "\\bottle\",
"quantity": 50,
"discount": ${ if (productName == "wine") { return 30 } else { return 0}}
"note": "Currency unit of ${GlobalVariable.productName} is \$."

  • Without \: note: Currency unit of ${GlobalVariable.productName} is $.
  • With \: note: Currency unit of wine is $.