I am writing automation test for my application but after installing the app. Device’s location permission dialog appears this from Android Native permission dialog (com.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity)
When I try to click on the Allow/Deny button it is not working and getting the following error.
Running ‘/Users/a/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“83f0374b42535532”,“shell”,“dumpsys”,“window”,“windows”]
[ADB] Found package: ‘com.android.packageinstaller’ and fully qualified activity name : ‘com.android.packageinstaller.permission.ui.GrantPermissionsActivity’
[ADB] Incorrect package and activity. Retrying.
[ADB] Getting focused package and activity
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[ADB] Running ‘/Users/a/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“83f0374b42535532”,“shell”,“dumpsys”,“window”,“windows”]
[ADB] Found package: ‘com.android.packageinstaller’ and fully qualified activity name : ‘com.android.packageinstaller.permission.ui.GrantPermissionsActivity’
[ADB] Incorrect package and activity. Retrying.
[ADB] Error: Error occured while starting App. Original error: ‘com.v.mastertestapplication.MainActivity’ never started
at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:63:13)
at ADB.callee$0$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:101:9)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
Error: Error occured while starting App. Original error: ‘com.v.mastertestapplication.MainActivity’ never started
at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:63:13)
at ADB.callee$0$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:101:9)
at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
I have tried the following workarounds but nothing works.
WorkAround 1:
protected By getPushNotificationButtonName() {
return By.id(“com.android.packageinstaller:id/permission_allow_button”);
}
public WebElement getQaButton() {
return AppiumHelper.waitElementToBeVisibleByLocator(getDriver(), getQaButtonElementName());
}
public void clickQaButton() throws Exception {
WebElement qaButton = getQaButton();
if (qaButton != null) {
qaButton.click();
} else {
elementNotFoundHandler(getQaButtonElementName());
}
}
WorkAround 2:
protected void allowAppPermission(AppiumDriver driver) {
while (driver.findElements(MobileBy.xpath("//*[@class=‘android.widget.Button’][1]")).size() > 0)
{
driver.findElement(MobileBy.xpath("//*[@class='android.widget.Button'][1]")).click();
}
}
Find Appium log here
The issue here is that when the permission dialog box overlay on the app, it is expecting the package name and activity of the permission dialog box and throwing this error
Error: Error occured while starting App. Original error: ‘com.v.mastertestapplication.MainActivity’ never started Found package: ‘com.android.packageinstaller’ and fully qualified activity name : ‘com.android.packageinstaller.permission.ui.GrantPermissionsActivity’ [ADB] Incorrect package and activity. Retrying. [ADB] Getting focused package and activity