.

ISSUE | SOLVED : com.android.contacts.ContactsListActivity - Permission to start activity denied.

Issue

If you are trying to dial a number using Appium, then you need to launch the dialer application. This is device specific. SO when I automated on Samsung S4 with contactsListActiviy, I faced this permission denied error.


Here are complete logs:

[36minfo [39m: [debug] Device is at API Level 21

[36minfo [39m: [debug] executing cmd: C:\Users\kamal\AppData\Local\Android\sdk\platform-tools\adb.exe -s 4a119f6b shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.contacts/com.android.contacts.ContactsListActivity"

[36minfo [39m: [debug] Stopping logcat capture

[31merror [39m: Permission to start activity denied.

[36minfo [39m: [debug] Logcat terminated with code null, signal SIGTERM




 

Solution:

Use package = com.android.contacts and activity = com.android.contacts.DialtactsContactsEntryActivity in desired capabilities.

capabilities.setCapability("appPackage", "com.android.contacts");

capabilities.setCapability("appActivity","com.android.contacts.DialtactsContactsEntryActivity");


Sample Test Case to dial a number using appium.

@Test()
 public void callNumber(){
  capabilities = new DesiredCapabilities();
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("deviceName", "4a119f6b");
  capabilities.setCapability("appPackage", "com.android.contacts");
  capabilities.setCapability("appActivity",
    "com.android.contacts.DialtactsContactsEntryActivity");
  capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,
    120);
  try {
   driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
     capabilities);
   
   
   List keypad = driver.findElements(By.id("com.android.contacts:id/tab_custom_layout"));
   keypad.get(0).click();
   
   driver.findElement(By.id("com.android.contacts:id/nine")).click();
   driver.findElement(By.id("com.android.contacts:id/six")).click();
   driver.findElement(By.id("com.android.contacts:id/five")).click();
   driver.findElement(By.id("com.android.contacts:id/zero")).click();
   driver.findElement(By.id("com.android.contacts:id/seven")).click();
   driver.findElement(By.id("com.android.contacts:id/four")).click();
   driver.findElement(By.id("com.android.contacts:id/zero")).click();
   driver.findElement(By.id("com.android.contacts:id/seven")).click();
   driver.findElement(By.id("com.android.contacts:id/six")).click();
   driver.findElement(By.id("com.android.contacts:id/zero")).click();
   
   driver.findElement(By.id("com.android.contacts:id/dialButton")).click();
   
 
  } catch (Exception e) {
   System.out.println("Error while executing call function.");
  }
 }

No comments :

Post a Comment

Recent Posts