Nandhini ravichandran
Nandhini ravichandran

Reputation: 25

How to write the test script for tapping a screen point in flutter integration testing without using flutter_test.dart package?

I use flutter_driver for integration testing in my application. I need to tap a screen point by passing an offset value in flutter driver testing, without using a flutter_test package

Upvotes: 1

Views: 495

Answers (1)

zerotje09
zerotje09

Reputation: 345

You might be able to do this using adb (Android Debug Bridge, a command-line tool for Android). This way you can perform actions, like a tap gesture, directly on the emulator. You need to make sure the adb path is correct though.

Let me give you a small example:

String adbPath() {
  return join(envVars['ANDROID_SDK_ROOT'] ?? envVars['ANDROID_HOME'], 'platform-tools', Platform.isWindows ? 'adb.exe' : 'adb');
}


void tap(int x, int y) {
  Process.run(_adbPath(), ['shell', 'input', 'tap', x.toString(), y.toString()]);
}

No need to import the flutter_test package.

Upvotes: 2

Related Questions