Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tap on Allow button on permission pop up

I am trying to click on the Allow button using Detox.

enter image description here

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.

like image 356
RonE Avatar asked May 28 '19 23:05

RonE


People also ask

How do I handle permission pop ups?

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.

How do I turn off permission control notifications?

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.

What does it mean when an app asks for permission?

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.


2 Answers

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

like image 168
Juan P. Ortiz Avatar answered Nov 07 '22 12:11

Juan P. Ortiz


This is not possible using Detox. The alert is presented from a different process, while Detox operates strictly in the app's process realm.

like image 24
Léo Natan Avatar answered Nov 07 '22 12:11

Léo Natan