In Flutter end-to-end testing, a permission is to be allowed during the test. driver.tap(find.text("ALLOW")
does not work. How to click "ALLOW".
Asked
Active
Viewed 2,085 times
12
![](../../users/profiles/824275.webp)
Kyaw Tun
- 10,164
- 7
- 44
- 72
1 Answers
14
You can grant the permissions before running the test.
import 'dart:io';
import 'package:path/path.dart';
// ...
setUpAll(() async {
final envVars = Platform.environment;
final adbPath = join(
envVars['ANDROID_SDK_ROOT'] ?? envVars['ANDROID_HOME'],
'platform-tools',
Platform.isWindows ? 'adb.exe' : 'adb',
);
await Process.run(adbPath, [
'shell',
'pm',
'grant',
'com.example.yourapp', // replace with your app id
'android.permission.RECORD_AUDIO'
]);
driver = await FlutterDriver.connect();
});
![](../../users/profiles/277580.webp)
apaatsio
- 1,778
- 1
- 16
- 17
-
2how to grant permission for iOS? – Saeed Jassani Nov 14 '20 at 01:52