Integrate flutter ui test with docker: drive test on headless chrome


I need to integrate flutter test drive into GitlabCI. I thing that easiest way to create a docker container (I use GitlabCI but you have the same problem if you use pure Docker or CircleCI or TravisCI or some pipeline into AWS or many other way) with chrome as device.
But I get this error:

 Found multiple connected devices:
test_drive_1  | Web Server • web-server • web-javascript • Flutter Tools
test_drive_1  | Chrome     • chrome     • web-javascript • Google Chrome 74.0.3729.108
test_drive_1  | Using device Web Server.
test_drive_1  | Starting application: test_driver/app.dart
test_drive_1  | Launching test_driver/app.dart on Web Server in release mode...
test_drive_1  | Compiling test_driver/app.dart for the Web...                      29.8s
test_drive_1  | test_driver/app.dart is being served at http://localhost:36571
test_drive_1  | Application finished.
test_drive_1  | Waiting for connection from Dart debug extension at http://localhost:36571
test_drive_1  | Unable to start WebDriver Session for Flutter for Web testing. 
test_drive_1  | Make sure you have the correct WebDriver Server running at 4444. 
test_drive_1  | Make sure the WebDriver Server matches option --browser-name. 
test_drive_1  | WebDriverException (61): invalid argument: perfLoggingPrefs specified, but performance logging was not enabled
test_drive_1  |   (Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Linux 4.15.0-33-generic x86_64)
flutter_test_app_test_drive_1 exited with code 0

The complete example is here.
To replicate the problem do this:

git clone
cd flutter_test_drive

cd docker
docker build -t flutter_test_drive .

cd ..
docker-compose up

The interesting file are the follow:

  • Dockerfile:
from cirrusci/flutter:stable

RUN sudo apt update && sudo apt install -y gdebi-core libnss3 libgconf-2-4
ADD google-chrome-stable_current_amd64.deb .
RUN sudo gdebi -n google-chrome-stable_current_amd64.deb

ADD chromedriver .
RUN sudo chmod +x chromedriver

# upgrade flutter
RUN cd /home/cirrus/sdks/flutter && git checkout master && git pull && flutter upgrade

RUN flutter config --enable-web && flutter doctor
/app/chromedriver --whitelisted-ips --port=4444 &
# nohup sh -c /app/chromedriver --whitelisted-ips &

flutter doctor
flutter pub get
flutter clean

# run test
flutter drive --target=test_driver/app.dart --release

kill $FOO_PID
  • docker-compose.yml
version: '3'

    image: flutter_test_drive
    - .:/flutter_project
    working_dir: /flutter_project
    command: "./"
    - '8000:8000'


I upgrade the chrome and chrome driver versions to latest and now it work! So this code version work well.

Answered By – Nicola Landro

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *