Recording Test Cases in Katalon Studio

Reusing test objects in test cases, especially for applications with consistent design patterns or shared components across different modules, can significantly enhance test efficiency and maintainability. This approach is particularly useful in platforms like Salesforce, where similar elements, such as combo boxes, might appear across different objects like Accounts, Leads, etc., with only slight variations in their identifiers or labels.

Strategies for Reusing Test Objects

  1. Parameterization of Test Objects
groovy

import com.kms.katalon.core.testobject.ConditionType
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

// Define the ID part dynamically
String dynamicId = 'combo-account' // This could be 'combo-lead', etc.

// Get the generic test object
TestObject comboBox = findTestObject('Object Repository/GenericComboBox')

// Modify its property to match the specific combo box needed
comboBox.modifyProperty('id', ConditionType.EQUALS, dynamicId)

// Use the modified test object in your test
WebUI.click(comboBox)
  1. Using Regular Expressions in Object Identification
Example of a Test Object Selector with Regex:
Assuming combo box IDs follow a pattern like combo-account-123, combo-lead-456, where the prefix is consistent, and the suffix is a numeric value.

Copy code
//input[starts-with(@id, 'combo-')]
  1. Centralized Object Repository

3. Centralized Object Repository

You structure your Object Repository to have shared objects that are common across different modules:


Object Repository/
├── Shared/
 └── GenericComboBox
├── Accounts/
 └── SpecificAccountField
└── Leads/
 └── SpecificLeadField

To make it more advanced a object repo simplified setup, for maintenance is created. While it is good that there are self healing capabilities and record a playback I always teach my testers internally and externally to think very well about an xpath and locator strategy, for maintenance purposes.

For this I created a combo object repo and an input field repo and reference the xpath name property as the field name. Most Salesforce master data names are implemented this way(at least for the default application) so this will improve the maintenance

WebUI.setText(findTestObject('Salesforce/Account/Masterdata_fields_Pageobjects/inputfields', [('inputfields') : 'Site']), site)
	WebUI.setText(findTestObject('Salesforce/Account/Masterdata_fields_Pageobjects/inputfields', [('inputfields') : 'AnnualRevenue']), annualRevenue)
	WebUI.setText(findTestObject('Salesforce/Account/Masterdata_fields_Pageobjects/inputfields', [('inputfields') : 'Phone']), phone)

Challenge

Please try to create your own parameters in salesforce using the https://github.com/learn-automated-testing/Katalon_Salesforce_Course project template