Find Mobile Objects

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 support selector strategies supported by Appium except for Android Data Matcher, including:

  1. Accessibility ID: it is the accessibility-id attribute of an object for XCUITest, and the content-desc attribute of an object for Android .

  2. 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)

  3. ID: native element identifier: resource-id for android; name for iOS.

  4. Name

  5. XPath (not recommended due to performance issues)

  6. Image: Locate an object by matching its image with a Base64 file

    Prerequisites:

    The element's image:

    The Base64-encoded string:

  7. Android UiAutomator

  8. Android View Tag

  9. iOS Predicate String

    Locate an object by iOS Predicate String

  10. iOS Class Chain

    Locate an object by iOS Class Chain

  11. Custom

    Learn more

In Script View

  1. 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")
  1. 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")
  1. 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")
  1. 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")
  1. 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]")
  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))
  1. Android 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)')
  1. 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")
  1. 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'")
  1. 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'`]")
  1. 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's 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 Windows 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:

Feedback