I am trying to click on the Allow button using Detox.
I have tried the following:
Detox: iOS Simulator how to confirm alert message
I have also tried targeting the "Allow" button by element(by.label('Allow')).tap()
and also by.text
I do not want to set location permissions upon app launch. I would like to simulate a user allowing and not allowing location permissions.
Handling permission pop-ups. While testing your mobile app, it may ask for specific permissions during the test. Various system dialogs or popups may appear, asking the user to grant access. The mobile app might ask the user permission to access the contacts, notifications, media, ... on the device.
Go to the phone's main Settings menu via the shortcut or the gear icon in the notification shade. Tap “Lock screen and security.” Towards the bottom of the list (on the Note 8, at least) is an entry marked “App permission monitor.” Tap the toggle next to it to turn this feature off completely.
You can allow some apps to use various features on your phone, such as your camera or contacts list. An app will send a notification to ask for permission to use features on your phone, which you can Allow or Deny. You can also change permissions for a single app or by permission type in your phone's Settings.
In your init.js
file you can allow the permissions:
beforeAll(async () => {
await detox.init(config, { launchApp: false });
await device.launchApp({newInstance: true, permissions: {notifications: 'YES'}});
});
Permissions:
calendar=YES|NO
camera=YES|NO
contacts=YES|NO
health=YES|NO
homekit=YES|NO
location=always|inuse|never
medialibrary=YES|NO
microphone=YES|NO
motion=YES|NO
notifications=YES|NO
photos=YES|NO
reminders=YES|NO
siri=YES|NO
You can check the documentation here: https://github.com/wix/detox/blob/master/detox/test/e2e/13.permissions.test.js
This is not possible using Detox. The alert is presented from a different process, while Detox operates strictly in the app's process realm.
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