0

我正在使用flutter_driver编写集成测试,以使用输入文本后必须输入(键盘事件)的文本字段进行搜索,我找不到在flutter_Driver中生成键盘事件的任何解决方案,有什么解决方案吗?

test('search tests, search a user by name', () async {
      print('Waiting for join now button');
      print('search  test started');
      await driver.clearTimeline();
      print('pause for 5 sec');
      await Future.delayed(Duration(seconds: 5));
      print('Tapping search field');
      await driver.waitFor(searchbar.searchFieldFinder);
      await driver.tap(searchbar.searchFieldFinder);
      print('enter user searching');
      await driver.enterText('Test user');

      //**Enter Keyboard Event here**  

    }, timeout: Timeout(Duration(minutes: 2)));
4

1 回答 1

1

对于集成测试中的键盘事件 ENTER,您可以使用以下代码:

  await tester.tap(find.byType(TextField));
  await tester.enterText(find.byType(TextField), text);
  await tester.testTextInput.receiveAction(TextInputAction.done);
  await tester.pumpAndSettle(Duration(seconds: 1));
于 2021-10-20T13:49:29.667 回答