When my Android app opens for the first time, it asks for notification and location permissions. I’m trying to use the Mobile Object Spy to capture the “Allow” button so I can click it, but the Spy tool completely ignores the popup! It’s like the popup doesn’t even exist. I can highlight things behind the popup, but not the actual buttons on it.
I did some googling and read that it’s because this is an Android system dialog, not a part of my actual app package. I tried manually creating a Mobile Object and guessing the XPath (like //android.widget.Button``[@text='Allow']), but when I run the script, it just times out and throws an ElementNotVisibleException.
How am I supposed to handle these native permissions if the Object Spy can’t see them? Do I need to change a setting in Katalon, or is there a trick to pressing these buttons? Any help would be appreciated!
Hi there, and thanks for posting in the Katalon community! 
To help you faster, please review our guide on Record Mobile Utility here:
Double-checking the steps and configurations might resolve the issue.
If the doc doesn’t help, feel free to provide more details, and a community member will assist you soon.
Thanks for being a part of our community!
Best,
Elly Tran
Hardcoding XPaths for system dialogs can be brittle because different Android OS versions (and manufacturer skins like Samsung or Xiaomi) alter the resource IDs and text of these buttons.
The industry-standard way to handle this in Katalon Studio is twofold:
-
The Desired Capabilities Approach (Preventative): If you don’t need to explicitly test the permission flow, you can tell Appium to auto-grant all permissions upon app launch.
-
The Dynamic Driver Approach (Reactive): If you must test the popup, we use a Custom Keyword that bypasses the Object Repository entirely, utilizing Appium’s driver to dynamically find the button by its text or resource ID.
Implementation Guide
Approach 1: Auto-Granting Permissions (Best Practice for Speed)
If your test suite isn’t explicitly testing if the permission dialog works, skip it entirely.
-
In Katalon Studio, navigate to Project > Settings > Desired Capabilities > Mobile > Android.
-
Add a new property:
Approach 2: Custom Keyword to Handle System Popups Dynamically
If you need to explicitly click “Allow” or “Deny”, use this custom keyword. It fetches the active Appium driver and performs a dynamic wait, ensuring your test doesn’t fail regardless of the OS skin.
Step 1: Create a New Custom Keyword Create a keyword package named com.mobile.helpers and add a keyword class named SystemDialogs:
Groovy
package com.mobile.helpers
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
import java.time.Duration
public class SystemDialogs {
/**
* Handles native Android permission popups by searching for the button text dynamically.
* @param buttonText The text of the button to click (e.g., "Allow", "While using the app", "Deny")
* @param timeoutInSeconds Time to wait for the popup to appear
*/
@Keyword
def handlePermissionPopup(String buttonText, int timeoutInSeconds) {
try {
// Retrieve the current active Appium driver from Katalon
AppiumDriver driver = MobileDriverFactory.getDriver()
// Define a dynamic locator strategy for native Android buttons
String xpathExpression = String.format("//android.widget.Button[contains(@text, '%s') or contains(@resource-id, '%s')]", buttonText, buttonText.toLowerCase())
// Explicitly wait for the system dialog button to be clickable
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(timeoutInSeconds))
WebElement permissionButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xpathExpression)))
permissionButton.click()
} catch (Exception e) {
println("System permission popup with text '" + buttonText + "' was not found within " + timeoutInSeconds + " seconds.")
}
}
}
Step 2: Use it in your Manual/Script View Now, you don’t need the Object Repository. Just call the keyword right after your app starts:
Groovy
Mobile.startApplication('Include/APK/your-app.apk', false)
// Handles the popup if it appears, waits up to 5 seconds
CustomKeywords.'com.mobile.helpers.SystemDialogs.handlePermissionPopup'('Allow', 5)
// Continue with your regular application testing
Mobile.tap(findTestObject('Object Repository/My_App/Login_Button'), 10)
@nghi.phan
Hey, is Elly_Tran still here in Katalon? I suspect not. I suppose that this forum has some script that automatically responds to any new post in the name of @Elly_tran. The administrator of this forum should change the forum setup to avoid the confusion.
hi @jfraney
Object Spy can’t grab system dialogs since they’re outside your app’s UI hierarchy. Two ways to deal with this.
skip it entirely by adding autoGrantPermissions (Boolean, true) under Project Settings > Desired Capabilities > Mobile > Android. Appium will just accept everything on launch.
if you need to actually interact with the popup, hit the Appium driver directly:
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver
import org.openqa.selenium.By
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
import java.time.Duration
AppiumDriver driver = MobileDriverFactory.getDriver()
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10))
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//android.widget.Button[@text='Allow']"))).click()
button text and IDs change across Android versions and OEM skins, so that XPath might need tweaking per device.
Thank you for your feedback, I will make sure to adjust the auto response.
This is a common issue in Android automation, and the good news is that nothing is wrong with Katalon or your Object Spy.
The reason the Spy cannot see the Allow Permissions popup is that Android permission dialogs belong to the system package (typically com.android.permissioncontroller or com.google.android.permissioncontroller), not your application. When Katalon is currently inspecting your app’s package, it may not be able to identify elements from the system dialog.
I guess the below solution will work
**Use Mobile Built-in Permission Handling
**
Instead of spying on the popup, use Appium/Katalon’s built-in capability to automatically grant permissions during app installation:
Mobile.startApplication('/path/to/app.apk', false)
MobileDriverFactory.getDriver().installApp('/path/to/app.apk')
Or enable the Appium capability:
autoGrantPermissions = true
This automatically accepts runtime permissions and avoids the popup altogether.
So why this will work:
For test automation, the cleanest solution is usually autoGrantPermissions=true unless your test case specifically needs to verify permission-denied or permission-allowed flows. This removes flakiness and avoids dependency on Android version-specific permission dialogs.
hi @jfraney
Object Spy can’t grab system dialogs since they’re outside your app’s UI hierarchy. Two ways to deal with this.
skip it entirely by adding autoGrantPermissions (Boolean, true) under Project Settings > Desired Capabilities > Mobile > Android. Appium will just accept everything on launch.
if you need to actually interact with the popup, hit the Appium driver directly:
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory
import io.appium.java_client.AppiumDriver
import org.openqa.selenium.By
import org.openqa.selenium.support.ui.ExpectedConditions
import org.openqa.selenium.support.ui.WebDriverWait
import java.time.Duration
AppiumDriver driver = MobileDriverFactory.getDriver()
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10))
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//android.widget.Button[@text='Allow']"))).click()
button text and IDs change across Android versions and OEM skins, so that XPath might need tweaking per device.
Please let us know about the issue, got resolved?