From 54194a9075443902ada0524fcb4012455a691348 Mon Sep 17 00:00:00 2001 From: yjbanov Date: Wed, 24 Feb 2016 11:31:16 -0800 Subject: [PATCH] wait for text to change in the sample driver test --- .../templates/driver/e2e_test.dart.tmpl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/templates/driver/e2e_test.dart.tmpl b/packages/flutter_tools/templates/driver/e2e_test.dart.tmpl index 02d80493df..e9307def98 100644 --- a/packages/flutter_tools/templates/driver/e2e_test.dart.tmpl +++ b/packages/flutter_tools/templates/driver/e2e_test.dart.tmpl @@ -32,13 +32,18 @@ main() { }); test('tap on the floating action button; verify counter', () async { + // Find floating action button (fab) to tap on ObjectRef fab = await driver.findByValueKey('fab'); expect(fab, isNotNull); + + // Tap on the fab await driver.tap(fab); - ObjectRef counter = await driver.findByValueKey('counter'); - expect(counter, isNotNull); - String text = await driver.getText(counter); - expect(text, contains("Button tapped 1 times.")); + + // Wait for text to change to the desired value + await driver.waitFor(() async { + ObjectRef counter = await driver.findByValueKey('counter'); + return await driver.getText(counter); + }, contains("Button tapped 1 times.")); }); }); }