Permissions capability in iOS

I’m testing on iOS using and Appium. There are alerts in certain parts of the app asking for permissions. I tried autoAcceptAlerts and it worked but then it broke other parts of the tests. I looked for another solution and found the permissions capability. It is granting permissions before the app starts and no permission alerts come out. The problem with the permissions capability is that it restarts the simulator everytime before each spec and appium has a hard time connecting and it takes so much time to start testing. Here are the logs:

appium-server-logs.txt (110.3 KB)

Grant permissions works only with Android as I remember…

You mean “autoGrantPermissions”? This is for Android only.

No, I mean this:

Ahh for Simulator! Yes it should work. But the way how it works indeed not nice I always prefer manual way in code to Accept permission on needed screen.

Yes I should have mentioned that. Sorry. It works but now it takes so much time to start testing. Simulator keeps shutting down and opening and it starts testing after couple minutes. I thought this would be a better approach than accepting alerts manually.

I use logic in loop e.g. after tap we can see permission and not ( maybe accepted at previos test) on some screen. So in loop execute tap accept permission with 1sec timeout for finding Accept button and find some unique element of needed page to appear with same 1sec timeout (found = break loop). Loop limited e.g. some reasonable time e.g. 20sec.

Ok. Will try that. Thanks!

Hi There, I am having a similar situation using iOS 14.1. (appium 1.17.1, python 3.7). Please help me with how to accept photo access permission. Thank you

@D_Ferrari You can use xPath. Something like “//XCUIElementTypeButton[@name=“Allow Access to All Photos”]” as selector.

Thank you Serra, yes it is worked, I had a hard time to find the element. But finally made it. thank you for your suggestion.

The type == 'XCUIElementTypeButton' AND name == 'Allow Access to All Photos' predicate selector should have better performance than xpath

Great, good to know. Thank you, Mykola.