Reputation: 169
await widgetTester.tap(find.byType(ElevatedButton));
shows warning : Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot receive pointer events.
Upvotes: 11
Views: 7848
Reputation: 1350
I just replace await tester.pump();
by await tester.pumpAndSettle();
before tap
It works for me.
Upvotes: 3
Reputation: 2023
I suggest creating a safeTapBy function logic. This just ensures that the button is visible (keyboard showing, off screen etc). Here is an example using find.byKey:
Future safeTapByKey(WidgetTester tester, String key) async {
await tester.ensureVisible(find.byKey(Key(key)));
await tester.pumpAndSettle();
await tester.tap(find.byKey(Key(key)));
}
Upvotes: 2
Reputation: 263
Try this:
await widgetTester.ensureVisible(find.byType(ElevatedButton));
await widgetTester.pumpAndSettle();
await widgetTester.tap(find.byType(ElevatedButton));
Upvotes: 26