Commit 54194a90 authored by yjbanov's avatar yjbanov

wait for text to change in the sample driver test

parent ccc9a25a
...@@ -32,13 +32,18 @@ main() { ...@@ -32,13 +32,18 @@ main() {
}); });
test('tap on the floating action button; verify counter', () async { test('tap on the floating action button; verify counter', () async {
// Find floating action button (fab) to tap on
ObjectRef fab = await driver.findByValueKey('fab'); ObjectRef fab = await driver.findByValueKey('fab');
expect(fab, isNotNull); expect(fab, isNotNull);
// Tap on the fab
await driver.tap(fab); await driver.tap(fab);
ObjectRef counter = await driver.findByValueKey('counter');
expect(counter, isNotNull); // Wait for text to change to the desired value
String text = await driver.getText(counter); await driver.waitFor(() async {
expect(text, contains("Button tapped 1 times.")); ObjectRef counter = await driver.findByValueKey('counter');
return await driver.getText(counter);
}, contains("Button tapped 1 times."));
}); });
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment