【发布时间】:2022-08-03 03:08:45
【问题描述】:
我正在寻找方法来查看我在测试中找到的小部件内部是否有某些文本。就我而言,我想查找的特定文本不在完整的 RadioButtonGroup 内,而是在找到的 ElevatedButton --> firstButton 内。可能吗?
testWidgets(\'Horizontal Radio Group builds a Row\', (tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: simpleRadio
));
expect(find.byType(Row), findsOneWidget);
expect(find.byType(Column), findsNothing);
var optionButtons = find.byType(ElevatedButton);
expect(optionButtons, findsNWidgets(2));
ElevatedButton firstButton = tester.firstWidget(optionButtons);
});
寻找类似的东西:expect(firstButton.findByText(\'bla\'), findsOneWidget);
标签: flutter dart flutter-test widget-test-flutter