My app need the multiple app permission. I need to check how my app behaves by allowing or denying the different permission. How can i enable/disable the app permission from the appium to create the multiple scenario?
For example lets say my app need to permissions: permission1
and permission2
.
scenario 1 = allow permission1 allow permission2
scenario 2 = allow permission1 deny permission2
scenario 3 = deny permission1 allow permission2
scenario 4 = deny permission1 deny permission2
Handle permission pop-ups 1 Grant all permissions for Android apps#N#To test Android apps, use Appium’s autoGrantPermissions capability to... 2 Allow or deny all permissions for iOS apps#N#To test iOS apps, use Appium’s autoAcceptAlerts and autoDismissAlerts... 3 Allow or Deny any permission pop-up for Android and iOS apps More ...
If you want to enable or disable permissions for a specific app, you’ll need to open its app settings on Windows. There are two ways you can go about that. Step 1: Open the Start menu and click on All apps at the top to view a list of installed apps. Step 2: Scroll down to locate the app for which you wish to configure permissions.
To test iOS apps, use Appium’s autoAcceptAlerts and autoDismissAlerts capabilities to handle app permissions. autoAcceptAlerts will automatically accept all permission pop-ups. autoDismissAlerts will automatically dismiss all permission pop-ups. This includes privacy access permission pop-ups (e.g., location, contacts, photos).
One caveat: the new capability only works for simulators, so those of you running on real devices will have to sit tight and keep manually automating those popups. Setup Because Appium relies on some newfangled 3rd-party software to make the permissions magic happen, we need to get said software on our machines before we try and run our test.
The above answers didn't resolve my problem. I solved this problem by using the the caps of "autoGrantPermissions".
Setup:
desired_caps['autoGrantPermissions'] = True
You will have to disable the noReset caps to False, otherwise it won't work. See reference here: http://appium.io/docs/en/writing-running-appium/caps/
Before you launch/initialise the appium driver, just give all the required permissions to the respective app through adb command as below so that the ALLOW pop up won't be displayed:
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_EXTERNAL_STORAGE
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.WRITE_EXTERNAL_STORAGE
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.ACCESS_FINE_LOCATION
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.CAMERA
adb -s yourDeviceSerialNumber shell pm grant your.app.packagename android.permission.READ_CONTACTS
You can call these through your automation code for android
OR
There is appium capabilities to grant permission : autoGrantPermissions Appium automatically determine which permissions your app requires and grant them to the app on install. Defaults to false. If noReset is true, this capability doesn't work.
http://appium.io/docs/en/writing-running-appium/caps/
One solution would be to go to Settings app and automate the scenario within that. You can go to Settings app (in fact, any iOS system app) by providing the bundle ID. For settings app it's com.apple.Preferences
I am using ruby, but the idea might be the similar for other clients.
def launch_settings_app
@driver.execute_script('mobile: launchApp', {'bundleId': "com.apple.Preferences"});
end
You can find other bundle IDs here https://emm.how/t/ios-11-list-of-default-apps-and-bundle-id-s/465 Or using command line - this will return bundle ids for all installed apps on your device: ideviceinstaller -u device_udid -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With