Profile PictureManoj Kumar
Open menu

FlutterDriver for Flutter Apps

January 14, 2019

(Updated on July 14, 2023)

article cover

FlutterDriver => It Provides API to test Flutter applications that run on real devices and emulators. The application runs in a separate process from the test itself.

It's simply called as Flutter’s version of Selenium Webdriver. If you know already Selenium getting started with FlutterDriver is easy.

If you want to know more about Flutter please check the official docs here. And More about Integration testing documentation on Driver Setup here.

You will need two test files to start with Flutter, let’s look at it now! You need to add flutter_driver dependency.

JAVA
dev_dependencies:
flutter_driver:
sdk: flutter
test: any
JAVA
void main() {
// This line enables the extension
enableFlutterDriverExtension();
// Call the `main()` function of your app or call `runApp` with any widget you
// are interested in testing.
app.main();
}

Secondly, its the test script itself

JAVA
void main() {
group('FlutterDriver demo', () {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if (driver != null) {
await driver.close();
}
});

Here is the sample script to give you a feel of how the test code (the API) calls looks like

JAVA
test('Flutter drive methods demo', () async {
await driver.tap(find.byValueKey('InputSting'));
await driver.enterText('Hello !');
await driver.waitFor(find.text('Hello !'));
await driver.waitForAbsent(find.text('Hello !'));
print('Hello!');

To execute the tests…

JAVA
$ flutter drive --target=test_driver/app.dart

I’m attempting to write an Appium driver for Flutter. The main goal of that attempt is to avoid people writing a new framework/ learn a new language(DART) to write tests to test Flutter Apps.

Stay tuned…..

update: Someone has already jumped on it before I could get onto it!

https://github.com/truongsinh/appium-flutter-driver

👍LIKE
❤️LOVE
👏CLAP
🎉PARTY

More articles

If you enjoyed this article, you'll find these insightful too!