flutter automatic testing : Tap on a button don't work in drawer
finally found a workaround : just need to add some delay before tapping in the drawer.
So I added
await tester.pump(const Duration(milliseconds: 100));
before tapping on buttons
I also ran into a similar issue.
The tester was able to find the FlatButton in the drawer:
expect(find.byType(FlatButton), findsOneWidget);
tester.tap did not appear to be working:
await tester.tap(find.byType(FlatButton));
But the solution mentioned in this Flutter issue did work:
FlatButton button = find.widgetWithText(FlatButton, 'TextExample').evaluate().first.widget;button.onPressed();
I haven't played with WidgetTest
yet, but I was able to achieve tapping on a button inside drawer, with flutter driver.
test('test button tap in drawer', () async { final SerializableFinder drawerOpenButton = find.byTooltip('Open navigation menu'); final SerializableFinder btn = find.byValueKey('firstButton'); await driver.waitFor(drawerOpenButton); await driver.tap(drawerOpenButton); await driver.waitFor(btn); await driver.tap(btn); print('tapped'); });
In main.dart
, I used key
property for the RaisedButton
I want to tap on.