A test driver for Flutter to do QA testing without sharing app source code.

Related tags

Templates autopilot
Overview

Autopilot

A test driver for Flutter to do QA testing without sharing app source code. It exposes a JSON API using an HTTP server running inside the app. Using these APIs you can write tests in any language for your Flutter app.

Getting started

Add package to pubspec:

dependencies:
  autopilot: ^0.0.2

For null safe version:

dependencies:
  autopilot: ^0.1.0

Create main_test.dart along side of your main.dart file. Make AutoPilot widget parent of your MaterialApp or root widget like below:

import 'package:flutter/material.dart';
import 'package:autopilot/autopilot.dart';

import 'my_app.dart';

void main() {
  runApp(
    Autopilot(child: MyApp())
  );
}

Run your app on device/emulator:

flutter run --release --target lib/main_test.dart

On Android forward port 8080 so that you can access it via localhost:

adb forward tcp:8080 tcp:8080

Consider following example:

Text(
  "Hello World!",
  key: Key("txtGreet"),
)

Example of a test in python using pytest:

# example_test.py
import requests

root = "http://localhost:8080"

def get(path):
    return requests.get(root + path).json()

def test_greet():
    greet = get("/texts?key=txtGreet")[0]
    assert greet["text"] == "Hello World!"

Run it:

python -m pytest example_test.py

Inspiration

Flutter has a really amazing testing suite for Unit, UI and Integration testing. But one problem is that you need to know/learn Dart and you have to share the source code of the app to the person who writes tests. This doesn't work in every work environments.

But Flutter framework is so transparent I was able to tap into its internals and build a JSON API which can provide pretty much everything you need to write UI automation tests.

APIs

GET /widgets

Returns entire widget tree

GET /keys

Returns list of all the keyed widgets

GET /texts

Returns list of all text widgets

GET /texts?text=<text>

Returns list of all text widgets with matching text

GET /texts?key=<key>

Returns text widget that matches key

GET /editables

Returns list of all text fields

GET /type?text=<text>

Types given text to the focused text field

GET /tap?x=<x>&y=<y>

Taps at given offset

GET /tap?key=<key>

Taps on widget with given key

GET /tap?text=<text>

Taps on text widget with given text

GET /hold?x=<x>&y=<y>

Tap and hold on given offset

GET /drag?x=<x>&y=<y>&dx=<dx>&dy=<dy>

Taps at (x,y) and drags (dx, dy) offset

GET /screenshot

Returns screenshot of app in PNG

GET /keyboard

Shows keyboard

DELETE /keyboard

Hides keyboard

POST /keyboard?type=<type>

Submits a keyboard action.

Some actions may not be available on all platforms. See TextInputAction for more information.

You might also like...

Android test task master - Create PIN code screen, authentication by PIN code screen and menu screen

Android test task master - Create PIN code screen, authentication by PIN code screen and menu screen

Here is described test tasks for a android dev. Need to implement three screens:

Oct 4, 2022

A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your issue.

A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your issue.

r_scan A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your iss

Nov 11, 2022

Open-source, cross-platform, hassle-free file sharing with AES-256 encryption made with Flutter & Dart.

Open-source, cross-platform, hassle-free file sharing with AES-256 encryption made with Flutter & Dart.

Odin ⚡ Open source easy file sharing for everyone. ⚡ Cross-platform hassle-free file sharing with AES-256 encryption made with Flutter & Dart. Getting

Dec 22, 2022

Win32 runner - Run a Flutter app without needing a lick of C/C++ code. Just Dart

Win32 runner - Run a Flutter app without needing a lick of C/C++ code. Just Dart

Experimental package for running Flutter apps from a Dart runner, instead of the

Sep 25, 2022

Create dart data classes easily, fast and without writing boilerplate or running code generation.

Create dart data classes easily, fast and without writing boilerplate or running code generation.

Dart Data Class Generator Create dart data classes easily, fast and without writing boilerplate or running code generation. Features The generator can

Feb 28, 2022

Bilgi Testi Flutter - A knowledge testing app built with Flutter

Bilgi Testi Flutter - A knowledge testing app built with Flutter

Bilgi Testi 7 sorudan oluşan puanlama mekaniği olan, modern tasarımlı, flutter i

Feb 9, 2022

🎬 Ditonton App is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Firebase Analytics & Crashlytics, Sqlite, Testing, CI/CD, etc.

🎬 Ditonton App is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Firebase Analytics & Crashlytics, Sqlite, Testing, CI/CD, etc.

Ditonton App Features Movies (Now Playing, Popular, Top Rated) TV Show (On The Air, Popular, Top Rated) Watchlist Movies & TV Show Search Movies & TV

Aug 12, 2023

🍕 FoodHub App is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Provider, Sqlite, Testing, Flash Dialog, Notification, Alarm Schedule, Dark Mode Theme, etc.

🍕 FoodHub App is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Provider, Sqlite, Testing, Flash Dialog, Notification, Alarm Schedule, Dark Mode Theme, etc.

FoodHub App Features List Restaurant Detail Restaurant Restaurant Favorite Search Restaurant Schedule Notification Dark Mode Theme Quick start This is

Jul 27, 2023

An app just for testing out Google Authentication using Firebase

An app just for testing out Google Authentication using Firebase

Google Authentication An app just for testing out Google Authentication using Fi

Feb 21, 2022
Comments
  • Flutter 2.0 Compilation Errors

    Flutter 2.0 Compilation Errors

    https://github.com/ajinasokan/autopilot/blob/93b8db41c739fdc059161b05925d48e4312575f8/lib/src/driver.dart#L208-L218

    Any of the code that creates a TestGesture is a compilation error after flutter 2.0. It looks like there isn't a hitTester param and the dispatcher function signature has changed to only accept a PointerEvent.

    I'm looking into submitting a pull request for these, but didn't know if you had any suggestions, @ajinasokan.

    opened by mjmarrazzo 9
  • GET /drag Doesn't Seem to be Working

    GET /drag Doesn't Seem to be Working

    I have a question about the /drag endpoint, because it doesn't seem to be working for me. The x and y params are the starting coordinates, are dx and dy supposed to be the end coordinates or just the offset on which it should move to? Trying to figure out if I'm giving it the wrong values.

    Basically we have a slider that I need to slide to trigger a "check out." I get the position of the Icon thats on the far left of the slider by calling /texts?key=$key. I've tried using a bunch of different things and nothing seems to work and I've tried looking at the _doDrag function and am getting lost inside of it.

    opened by mjmarrazzo 8
  • adding POST /keyboard?type=<type>

    adding POST /keyboard?type=

    I added in all the current supported actions from here. Some of them aren't available on all platforms. Wasn't sure how you might want to handle that (or if we want to at this point).

    Pull Request for #3

    opened by mjmarrazzo 2
  • Keyboard Submit

    Keyboard Submit

    Testing an app for work, and we have a search bar and there isn't a search button, cause you would typically press enter after the search term. We are using both autopilot to handle all flutter things and appium for handling system dialog and permissions. We could do a workaround with appium, but we're trying to use it as least as possible.

    So I'm looking for a way to send a keyboard submit with autopilot. Have tried adding in various line endings, but nothing seems to work. Still looking into ways to do this, but if you have any input, that would be great.

    opened by mjmarrazzo 2
Owner
Ajin Asokan
App developer @zerodha
Ajin Asokan
Custom flutter testing CLI tool for individual test runs and group testing

fluttertest Custom flutter testing CLI tool for inidividual test runs or group testing Overview Flutter is a great framework which has helps developer

vi_mi 15 Nov 6, 2022
The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage.

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage (using Android and iOS

The Mobile Applications Community 2 Apr 7, 2022
Simple and complete Flutter hooks testing utilities that encourage good testing practices.

Flutter Hooks Testing Library Simple and complete Flutter hooks testing utilities that encourage good testing practices. Inspired by react-hooks-testi

Daichi Furiya 24 Dec 2, 2022
A simple test testing swagger_dart_code_generator 2.2.5+1

m_work_swagger_test_2 A simple test testing swagger_dart_code_generator 2.2.5+1 Was created like this: Create an ordinary Flutter project in AS2020.3.

Roar Grønmo 0 Nov 15, 2021
Value listenable test - Assists in testing ValueListenable objects (ex: ValueNotifier).

value_listenable_test Assists in testing ValueListenable objects (ex: ValueNotifier). install Added in your pubspec.yaml as dev dependency: dev_depend

Flutterando 3 Feb 23, 2022
A Flutter mobile application built completely using DhiWise and Supabase without coding single line of code. With 100% system generated code

Flutter Expension Getting Started with Flutter ?? Generated with ❤️ from Dhiwise A Flutter mobile application built completely using DhiWise and Supab

DhiWise 11 Oct 23, 2022
Flutter bloc cubit test knowdge - Flutter bloc cubit test knowdge

Flutter Bloc Simple Api This project is using weather api for featch data and di

Waruna Kaushalya 0 Jan 3, 2022
Integration test - Copy of the official Flutter integration test plugin

integration_test This package enables self-driving testing of Flutter code on de

null 0 Jan 5, 2022
Integration Test Preview allows tests on multiple screen sizes in a single e2e test run.

Integration Test Preview has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage (using Android and iOS pl

The Mobile Applications Community 3 Aug 23, 2022