Authorizing camera access for integration test

1,224 views
Skip to first unread message

Ryan Hanks

unread,
Apr 2, 2018, 4:22:47 PM4/2/18
to Flutter Dev
Hi,

My app needs access to the camera. When I run integration tests on iOS (as described here), the app prompts for permission to access the camera on launch, and I need to grant that permission by tapping "OK" to be able to test the app. 

How should I be handling this? Is there a way for the app to be built so that this permission prompt can be avoided? Is there a way to use the flutter driver to grant the permission? I'm assuming the driver's "tap" method would not allow me to interact with this dialog, let me know if you think this is incorrect..

Thanks
Ryan

Ryan Hanks

unread,
Apr 2, 2018, 4:48:56 PM4/2/18
to Flutter Dev
One thing worth mentioning here is that the driver doesn't seem to be able to reuse an instance of the app that I've manually granted access to. For example, if I create a pause in my test script during which I manually tap on the "OK" in the dialog to allow access to the camera, I have to repeatedly do this for every test execution. When I launch my app using "flutter run", it remembers that I've given permission to access the camera, and I only have to grant access the one time.

Yegor Jbanov

unread,
Apr 3, 2018, 2:01:56 PM4/3/18
to Flutter Dev
The permission confirmation screen is outside of our control unfortunately. It's an operating system level dialog that we cannot bypassed using FlutterDriver alone.

As for the app where you manually grant permission, make sure that driver does not reinstall the app (thus losing the previously granted permissions). You can use the `--use-existing-app` option. However, this option assumes that something else launches the app before you run the test script. Unfortunately we don't have a way to launch a preinstalled app (please file a feature request if that's important to you). You should be able to use libimobiledevice to achieve this effect though.
Reply all
Reply to author
Forward
0 new messages