clear_app_data resets all permissions

28 views
Skip to first unread message

Kristina Stemikovskaya

unread,
Sep 21, 2016, 8:41:50 AM9/21/16
to calabash-android
Hi, I have a problem with Android permissions. 

I have a hook which uses clear_app_data when my scenario fails, to reset app of possible artifacts left after incomplete test execution: 

  if scenario.failed?
    clear_app_data
  end

But starting from android M in the consequent tests app asks for permissions at login and it causes all the consequent test to fail. 

Could you please advice me, how can I restore permissions after clear_app_data?  


Message has been deleted

Marcella

unread,
Sep 21, 2016, 8:18:59 PM9/21/16
to calabash-android
You can use Android's Package Manager to grant the permission(s) you need after calling the clear_app_data method. Here are all the package manager commands - https://developer.android.com/studio/command-line/shell.html#pm

So, something like
adb shell pm grant <PACKAGE_NAME> <PERMISSION>

Kristina Stemikovskaya

unread,
Sep 30, 2016, 6:38:10 AM9/30/16
to calabash-android
Thank you Marcella, I've added a method to my app routine which gives all  necessary permissions after executing clear_app_data, works like a charm! 
Reply all
Reply to author
Forward
0 new messages