Open DimitarStoyanov91 opened 6 months ago
Hi, the easiest solution to make this test passing is to close keyboard manually by putting await $.native.pressBack();
after line 18 in edit_fields_test.dart
.
Keyboard's behaviour seems unexpected so I'll try to come back to this case, maybe we can fix that in patrol.
Let me know if it solves all cases you have.
@fylyppo Thanks for the fast response! Unfortunately this doesn't seem to be a good workaround for us, since we have a lot of tests and we have a lot of places with this widget. This will require refactoring to most of our tests. We will wait for a more generic fix, before we jump into workarounds. I am available for more comments, questions, etc.
@DimitarStoyanov91 any chance it is related to this: https://github.com/leancodepl/patrol/pull/2111#issuecomment-2079825193 ?
Hello @b055man, It seems the second part fits our issue "the keyboard does not close when the text field edit is done / the focus is lost - it stays on forever (can't really close it even when tapping back in the emulator)", please keep in mind @fylyppo noted this "Hi, the easiest solution to make this test passing is to close keyboard manually by putting await $.native.pressBack(); after line 18 in edit_fields_test.dart.". However, I can not confirm this part "Also, these tests worked fine with previous Patrol (2.3.2) and as mentioned they work fine if 2.0.1+1 version of the package is used."
Have the same problem. Got 3 solutions atm in my tests code.
Would very much like a fix for this.
Steps to reproduce
patrol test --target integration_test/tests/edit_fields_test.dart
Actual results
We have a widget with autofocus on the input field, which causes the keyboard to appear. The normal flow would be that the keyboard hides after clicking a "Save" button. Unfortunately when the test clicks "Save" the keyboard stays on the screen and hides other widgets underneath it. We tried $.native.tap() on some elements on the screen, but that did not hide the keyboard.
Update: Tried also this approach: Future nativeEnterText(var widget, String inputText) async { await $(widget).tap(): await checkWidgetVisibility(widget); await $.native.enterText(Selector(focused: true), text: inputText, keyboardBehavior: KeyboardBehavior.showAndDismiss); }
This works fine for positive cases, but fails to enter the text when there are multiple invalid inputs
for that field and a final step with valid input that is accepted.
Logs
There are no log errors.
Patrol version
Patrol version: 3.6.1 patrol_cli version: 2.7.0 Device: Android 13.0 Pixel XL API 33
Patrol Doctor output
Patrol doctor: Patrol CLI version: 2.7.0 Flutter command: flutter Flutter 3.16.3 • channel stable Android: • Program adb found in /opt/homebrew/bin/adb • Env var $ANDROID_HOME set to /Users/dimitar.stoyanov/Library/Android/sdk iOS / macOS: • Program xcodebuild found in /usr/bin/xcodebuild • Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller
Flutter Doctor output
[✓] Flutter (Channel stable, 3.16.3, on macOS 14.1.2 23B92 darwin-arm64, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] IntelliJ IDEA Community Edition (version 2022.3.1) [✓] Connected device (2 available) [✓] Network resources