Repository: flutter
Issue: Flutter Test Driver: find.bySemanticsLabel missing documentation
Labels: tool,d: examples,t: flutter driver,P3,team-tool,triaged-tool

I'm having difficulties understanding how `find.bySemanticsLabel` works inside an `integration test`.  
There doesn't seem to be one single example inside the documentation.
Following test is the easiest example which it think should work, however it fails.

What am I missing?

**simple_semantics_test.dart**
```
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
  group("bySemanticsLabel test", () {
    FlutterDriver driver;

    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    test("click by semantics", () async {
      await driver.tap(find.bySemanticsLabel(RegExp('testLabel')));
      //Do note that I tried `await driver.tap(find.bySemanticsLabel("testLabel")` too.
    });

    tearDownAll(() async {
      await driver.close();
    });
  });
}
```


**simple_semantics.dart**
```
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';

void main() {
  enableFlutterDriverExtension();
  runApp(MaterialApp(
    home: Scaffold(
      body: Container(
        child: Center(
          child: Semantics(
            label: "testLabel",
            child: FlatButton(
              child: Text("rguhergeugr"),
              onPressed: () {},
            ),
          ),
        ),
      ),
    ),
  ));
}
```

Which fails with the following error message

```
flutter drive --target=test_driver/simple_semantics.dart
Using device Android SDK built for x86.
Starting application: test_driver/simple_semantics.dart
Initializing gradle...                                              0.6s
Resolving dependencies...                                           1.8s
Installing build/app/outputs/apk/app.apk...                         3.0s
Running Gradle task 'assembleDevDebug'...                               
Running Gradle task 'assembleDevDebug'... Done                      4.5s
Built build/app/outputs/apk/dev/debug/app-dev-debug.apk.
Installing build/app/outputs/apk/app.apk...                         2.8s
I/flutter (10928): Observatory listening on http://127.0.0.1:44027/2b8-xlSds4o=/
00:00 +0: Semantics Screen (setUpAll)
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:52142/2b8-xlSds4o=/
[trace] FlutterDriver: Isolate found with number: 898244776
[trace] FlutterDriver: Isolate is not paused. Assuming application is ready.
[info ] FlutterDriver: Connected to Flutter application.
00:00 +0: Semantics Screen click by semantics
[warning] FlutterDriver: tap message is taking a long time to complete...
00:30 +0 -1: Semantics Screen click by semantics [E]
  TimeoutException after 0:00:30.000000: Test timed out after 30 seconds.
  package:test_api/src/backend/invoker.dart 324:28              Invoker._handleError.<fn>
  dart:async/zone.dart 1120:38                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  package:test_api/src/backend/invoker.dart 322:10              Invoker._handleError
  package:test_api/src/backend/invoker.dart 275:9               Invoker.heartbeat.<fn>.<fn>
  dart:async/zone.dart 1124:13                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  package:test_api/src/backend/invoker.dart 273:38              Invoker.heartbeat.<fn>
  package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 119:48  StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1124:13                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  dart:async/zone.dart 947:23                                   _CustomZone.bindCallback.<fn>
  dart:async-patch/timer_patch.dart 21:15                       Timer._createTimer.<fn>
  dart:isolate-patch/timer_impl.dart 382:19                     _Timer._runTimers
  dart:isolate-patch/timer_impl.dart 416:5                      _Timer._handleMessage
  dart:isolate-patch/isolate_patch.dart 172:12                  _RawReceivePortImpl._handleMessage
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                                  _CustomZone.registerCallback
  dart:async/zone.dart 946:22                                   _CustomZone.bindCallback
  dart:async/zone.dart 1191:21                                  _rootCreateTimer
  dart:async/zone.dart 1088:19                                  _CustomZone.createTimer
  package:test_api/src/backend/invoker.dart 272:34              Invoker.heartbeat
  package:test_api/src/backend/invoker.dart 235:5               Invoker.waitForOutstandingCallbacks
  package:test_api/src/backend/declarer.dart 166:33             Declarer.test.<fn>.<fn>
  dart:async/zone.dart 1124:13                                  _rootRun
  dart:async/zone.dart 1021:19                                  _CustomZone.run
  dart:async/zone.dart 1516:10                                  _runZoned
  dart:async/zone.dart 1463:12                                  runZoned
  package:test_api/src/backend/declarer.dart 165:13             Declarer.test.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                                  _CustomZone.registerCallback
  dart:async/zone.dart 962:22                                   _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52:45                                   new Timer
  dart:async/timer.dart 87:9                                    Timer.run
  dart:async/future.dart 174:11                                 new Future
  package:test_api/src/backend/invoker.dart 391:21              Invoker._onRun.<fn>.<fn>.<fn>

00:30 +0 -1: Semantics Screen (tearDownAll)
00:30 +0 -1: Semantics Screen click by semantics [E]
  DriverError: Failed to fulfill Tap due to remote error
  Original error: Bad state: The client closed with pending request "ext.flutter.driver".
  Original stack trace:
  #0      new Client.withoutJson.<anonymous closure> (package:json_rpc_2/src/client.dart:70:24)
  #1      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
  #2      StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
  #3      _rootRun (dart:async/zone.dart:1120:38)
  #4      _CustomZone.run (dart:async/zone.dart:1021:19)
  #5      _FutureListener.handleWhenComplete (dart:async/future_impl.dart:150:18)
  #6      Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:609:39)
  #7      Future._propagateToListeners (dart:async/future_impl.dart:665:37)
  #8      Future._propagateToListeners (dart:async/future_impl.dart:566:9)
  #9      Future._completeWithValue (dart:async/future_impl.dart:483:5)
  #10     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
  #11     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
  #12     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
  #13     _rootRun (dart:async/zone.dart:1124:13)
  #14     _CustomZone.run (dart:async/zone.dart:1021:19)
  #15     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
  #16     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
  #17     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
  #18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
  #19     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
  #20     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
  #21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)


  package:flutter_driver/src/driver/driver.dart 426:7   FlutterDriver._sendCommand
  ===== asynchronous gap ===========================
  dart:async/future_impl.dart 22:43                     _Completer.completeError
  dart:async-patch/async_patch.dart 40:18               _AsyncAwaitCompleter.completeError
  package:flutter_driver/src/driver/driver.dart         FlutterDriver._sendCommand
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1062:19                          _CustomZone.registerBinaryCallback
  dart:async-patch/async_patch.dart 86:23               _asyncErrorWrapperHelper
  package:flutter_driver/src/driver/driver.dart         FlutterDriver._sendCommand
  package:flutter_driver/src/driver/driver.dart 459:11  FlutterDriver.tap
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053:19                          _CustomZone.registerUnaryCallback
  dart:async-patch/async_patch.dart 77:23               _asyncThenWrapperHelper
  package:test_api/src/backend/declarer.dart            Declarer.test.<fn>.<fn>.<fn>
  package:test_api/src/backend/invoker.dart 242:15      Invoker.waitForOutstandingCallbacks.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045:19                          _CustomZone.registerCallback
  dart:async/zone.dart 962:22                           _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52:45                           new Timer
  dart:async/timer.dart 87:9                            Timer.run
  dart:async/future.dart 174:11                         new Future
  package:test_api/src/backend/invoker.dart 391:21      Invoker._onRun.<fn>.<fn>.<fn>

00:30 +0 -1: Some tests failed.

Unhandled exception:
Dummy exception to set exit code.
#0      _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:1112:29)
#1      _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#2      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#3      _Timer._runTimers (dart:isolate-patch/timer_impl.dart:391:30)
#4      _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
Stopping application instance.
Driver tests failed: 255
```