Locators and Object Identification in Katalon Studio
Locator Strategies for detecting a mobile object
Before version 7.6, Katalon Studio only supports the Attributes Selection Method that allows selecting an object’s properties to generate its selector. The generated selector can be XPATH selector or in some cases, Android UiSelector. From 7.6, Katalon Studio fully supports selector strategies supported by Appium except for Android Data Matcher, including:
-      Accessibility ID: it is the accessibility-idattribute of an object for XCUITest, and thecontent-descattribute of an object for Android . 
 
-      Class name: for IOS it is the full name of the XCUI element and starts with XCUIElementType; for Android it is the full name of the UIAutomator2 class (e.g.: android.widget.TextView)  
 
-      ID: native element identifier: resource-idfor android;namefor iOS. 
 
-      Name  
 
-      XPath (not recommended due to performance issues)  
 
-      Image: Locate an object by matching its image with a Base64 file Prerequisites: - Set up Image-based Testing for Mobile
- An active Katalon Studio Enterprise license
 The element's image:  
 The Base64-encoded string:  
 
-      Android UiAutomator  
 
-      Android View Tag  
 
-      iOS Predicate String You can learn more about locating an object by iOS Predicate String in the Appium document: Locate an object by iOS Predicate String.  
 
-      iOS Class Chain You can learn more about locating an object by iOS Class Chain in the Appium document: Locate an object by iOS Class Chain.  
 
-      Custom You can learn more about locating elements by custom strategy in the Appium document: Using Element Plugins.  
 
In Script View
- Accessibility ID      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.ACCESSIBILITY)
 mobileObject.setMobileLocator("ImageView")
- Class name      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.CLASS_NAME)
 mobileObject.setMobileLocator("General")
- ID      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.ID)
 mobileObject.setMobileLocator("General")
- Name      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.NAME)
 mobileObject.setMobileLocator("General")
- XPath      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.XPATH)
 mobileObject.setMobileLocator("//XCUIElementTypeApplication/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeTable[1]/XCUIElementTypeCell[2]/XCUIElementTypeStaticText[1]")
- Image      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import org.apache.commons.io.FileUtils
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.IMAGE)
 byte[] fileContent = FileUtils.readFileToByteArray(new File(imageFilePath))
 mobileObject.setMobileLocator(Base64.getEncoder().encodeToString(fileContent))
- Andoid UIAutomator      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.ANDROID_UI_AUTOMATOR)
 mobileObject.setMobileLocator('new UiSelector().className("android.widget.TextView").text("General").resourceId("android:id/title").packageName("com.android.settings").enabled(true).clickable(false).longClickable(false).checkable(false).checked(false).focusable(false).focused(false).scrollable(false).selected(false).index(0)')
- Android View Tag      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.ANDROID_VIEWTAG)
 mobileObject.setMobileLocator("MY VIEW TAG")
- iOS Predicate String      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.IOS_PREDICATE_STRING)
 mobileObject.setMobileLocator("type == 'XCUIElementTypeStaticText' AND enabled == 1 AND label == 'General' AND name == 'General' AND name == 'General'")
- iOS Class Chain      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.IOS_CLASS_CHAIN)
 mobileObject.setMobileLocator("**/XCUIElementTypeStaticText[`enabled == 1 AND label == 'General' AND name == 'General' AND value == 'General'`]")
- Custom      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
 import com.kms.katalon.core.testobject.MobileTestObject
 import com.kms.katalon.core.testobject.MobileTestObject.MobileLocatorStrategy
 MobileTestObject mobileObject = findTestObject("Object Repository/New Mobile Object")
 mobileObject.setMobileLocatorStrategy(MobileLocatorStrategy.CUSTOM)
 mobileObject.setMobileLocator("foo")
Mobile Test Object View
In versions before 7.6, a Mobile object's view is the same as a Web object's view, which is not intuitive and misleading for users to design a Mobile test object. From 7.6 onwards, Katalon Studio launches a new UI of Mobile Test Object's view that reflects our latest enhancements for better designing Mobile objects.
Mobile Object Spy
In previous versions, you can capture and rename captured objects but cannot change a Mobile object’s locator nor verify and highlight them. From version 7.6, you can capture, edit, verify and highlight a captured object to optimize its locator.
   
 
The Object Properties section now allows:
- Editing locator and locator strategy of an object.
- Verifying and highlighting the object with the newly updated locator.
   
Mobile Recorder
In previous versions, in Mobile Recorder you can stimulate Mobile actions but cannot add built-in actions like in Web Recorder. From version 7.6, Katalon Studio supports adding built-in and custom actions when recording.
The new UI is similar to the Mobile Recorder.
   
Recorded Actions:
   
 
Captured Objects:
   
 
Known Limitation
Katalon Studio currently doesn’t support Android Data Matcher since Appium Java Client 7.1.0 doesn’t support Android Data Matcher.
See also: