Repository navigation
[Flutter Driver] How to submit a TextField? #29450
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.t: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to Reproduce
- Create a TextField inside the app with an onSubmitted handler.
- Write a driver test case that inputs text into it
(so far, this works flawlessly)
But now what, how can I submit the TextField to trigger onSubmitted without creating a separate UI element that does that when tapped?
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17134.648], locale en-DE)
• Flutter version 1.2.1 at G:\FlutterSDK
• Framework revision 8661d8aecd (4 weeks ago), 2019-02-14 19:19:53 -0800
• Engine revision 3757390fa4
• Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at G:\AndroidSDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = G:\AndroidSDK
• Java binary at: G:\Program Files\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.3)
• Android Studio at G:\Program Files\Android Studio
• Flutter plugin version 33.3.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.t: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
t-artikov commentedon May 9, 2019
@yjbanov @Hixie
Any comments please?
The use of FlutterDriver is quite limited without this feature.
yjbanov commentedon May 18, 2019
Would it be possible to use FlutterDriver.requestData and trigger the submission programmatically?
t-artikov commentedon May 18, 2019
@yjbanov
It's possible, I suppose, but it is not great if a user has to add application logic just for testing.
It would be better if FlutterDriver was able to submit text input.
khari998 commentedon Apr 21, 2020
Please add functionality for this in testing. I am having the same issue
andrei1489 commentedon May 13, 2020
One workaround for this that I found is based on what @yjbanov said.
You disable TextEntryEmulation, then on app side you register a new TestTextInput. Then back in the test, you tap on the input field, which triggers TextInput.setClient.
app.dart :
app_test.dart:
markusaksli-nc commentedon Jul 29, 2020
This is probably going to be blocked until #9383 is done.
Ibessas commentedon Feb 18, 2021
Any update?
omatt commentedon Aug 23, 2021
Now that Flutter recommends writing integration tests with the
integration_testpackage as mentioned in this doc, this feature might be less likely to be pushed any time soon.The workaround that I did was by using the integration_test package, following this post.
On the app:
hardik-kumbhani commentedon Feb 18, 2022
@omatt It's really works good for me Thanks
dkwingsmt commentedon Jul 15, 2022
Now that #106561 has landed, is this issue completed?
desmond206x commentedon Sep 18, 2025
It would be helpful to let the integration test run with the
flutter runcommand to be faster, but it does not work because of text input isn't working. I test integration test for web in chrome if it helps..