1

Implementing some integration_test for flutter-web application wherein I'm trying to simulate keyboard action to clear the content of the TextField(). Like we have for "Done" like: await tester.testTextInput.receiveAction(TextInputAction.done);

Any idea how to do that?

Rajesh Patil
  • 181
  • 2
  • 10

1 Answers1

1

You can simulate keyboard presses in your test like this:

await simulateKeyDownEvent(LogicalKeyboardKey.backspace);

https://api.flutter.dev/flutter/flutter_test/simulateKeyDownEvent.html

Er1
  • 2,559
  • 1
  • 12
  • 24
  • .Tried with the sample hello world counter application to clear the initial text from TextFormField but "await tester.sendKeyDownEvent(LogicalKeyboardKey.backspace);" seems to have no effect. Raised issue in official repo....incase i am doing anything wrong let me know. https://github.com/flutter/flutter/issues/97502 – Rajesh Patil Jan 31 '22 at 05:20
  • @RajeshPatil To be clear, I said `simulateKeyDownEvent` not `tester.sendKeyDownEvent` – Er1 Jan 31 '22 at 09:03
  • no effect still the same result...fails with the same error(means one was found but none were expected)....but i suspect if i refer to the internal implementation its says platforms (e.g. Windows, iOS) are not yet supported. – Rajesh Patil Jan 31 '22 at 09:16