Features

Automated Flutter App Testing

TestingBot supports automated testing of Flutter apps via Appium's Flutter Driver.

To get started, please make sure to follow these steps:

  1. Compile your Flutter app in debug or profile mode.
    Appium's Flutter driver does not currently support apps built in release mode.

  2. Make sure your app's pubspec.yaml file contains:

    dev_dependencies:
      test: any
      flutter_test:
       sdk: flutter
      flutter_driver:
       sdk: flutter
  3. Import the new dev_dependencies that you have added in the previous step:

    flutter pub get
  4. Next, import the flutter_driver_extension library in your main.dart file:

    import 'package:flutter_driver/driver_extension.dart';
  5. Your main.dart file should contain enableFlutterDriverExtension() before runApp.

    void main() {
        enableFlutterDriverExtension();
        runApp(MyApp());
     }
  6. The automationName in your desired capabilities should be set to Flutter.

    caps = Selenium::WebDriver::Remote::Capabilities.new
    caps["automationName"] = "Flutter"
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setCapability("automationName", "Flutter");
    $caps = array(
      "automationName" => "Flutter"
    );
    capabilities = {
      "automationName" : "Flutter"
    }
    const capabilities = {
      "automationName" : "Flutter"
    }
    DesiredCapabilities caps = new DesiredCapabilities();
    caps.SetCapability("automationName", "Flutter");

Preparing your App

You can build an .apk file for Android, .ipa file for iOS physical devices or .app bundle for iOS Simulator testing.

This file needs to be uploaded to TestingBot for automated or manual testing.

Please see the table below on how to build your app:

OS Build Mode Command
Android debug
flutter build apk --debug
profile
flutter build apk --profile
iOS debug
flutter build ios --debug
simulator
flutter build ios --simulator
profile
flutter build ios --profile
  • For iOS 14 and higher, please build the app in profile mode only.
  • Release mode is not supported by Appium's Flutter Driver.
  • For iOS real device testing, please use flutter build ipa, then do:
    mkdir Payload
    mv Runner.app Payload/
    zip --symlinks -qr test-app.ipa Payload

Uploading Your App

Please see our Upload Mobile App documentation to find out how to upload your app to TestingBot for testing.

Example

TestingBot has created a flutter-demo-app which you can use to run your first Flutter Automated test with TestingBot.

Please see the example below where we run an automated Flutter test on TestingBot.

const wdio = require('webdriverio');
const assert = require('assert');
const { byValueKey } = require('appium-flutter-finder');

const caps = {
  platformName: 'Android',
  deviceName: 'Pixel 6',
  version: '12.0',
  realDevice: true,
  app: 'https://github.com/testingbot/flutter-demo-app/releases/download/v1.0.0/demo.apk' // or tb://[yourapp]'
};

const opts = {
  capabilities: {
    ...caps,
    automationName: 'Flutter',
    retryBackoffTime: 500,
    hostname: 'hub.testingbot.com'
  },
  user: '...',
  key: '...'
};

(async () => {
  const counterTextFinder = byValueKey('counter');
  const buttonFinder = byValueKey('incrementButton');

  const driver = await wdio.remote(opts);

  assert.strictEqual(await driver.getElementText(counterTextFinder), '0');

  await driver.elementClick(buttonFinder);
  await driver.touchAction({
    action: 'tap',
    element: { elementId: buttonFinder }
  });

  assert.strictEqual(await driver.getElementText(counterTextFinder), '2');

  driver.deleteSession();
})();

This example test will open the flutter-demo-app, find both the counter number and increment button by valueKey.
It will then verify the initial number, click the button twice and verify if the number is correct.

You can use the following demo applications to try out automated Flutter testing:

  • For iOS simulator testing:
    https://github.com/testingbot/flutter-demo-app/releases/download/v1.0.0/demo-ios-simulator.zip
  • For iOS physical device testing:
    https://github.com/testingbot/flutter-demo-app/releases/download/v1.0.0/demo.ipa
  • For Android testing:
    https://github.com/testingbot/flutter-demo-app/releases/download/v1.0.0/demo.apk

Specify Devices

To run your existing tests on TestingBot, your tests will need to be configured to use the TestingBot remote devices. If the test was running on your local machine or network, you can simply change your existing test like this:

To let TestingBot know on which device you want to run your test on, you need to specify the deviceName, version, platformName and other optional options in the capabilities field.

1. Select a Device Type
2. Select a Device Name

Additional Options

Appium provides multiple Flutter capabilities to configure your test.

Additionally, you can use Flutter Finders and Flutter Commands.