Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Keyboard does NOT close by any action after beeing opened by autofocus on inputfield widget. #2202

Open
DimitarStoyanov91 opened this issue May 21, 2024 · 5 comments
Labels
bug Something isn't working P2 Issues not at the top of the work list package: patrol Related to the patrol package (native automation, test bundling) platform: android Android is affected

Comments

@DimitarStoyanov91
Copy link

Steps to reproduce

  1. Create emulator Pixel XL API 33 in Android Studio
  2. Clone 'git@github.com:Prime-Holding/widget_toolkit.git'
  3. Open in Android Studio widget_toolkit->packages->widget_toolkit->example
  4. Checkout branch 'fix-patrol-debug'
  5. Check test 'edit_fields_test.dart'
  6. Run command 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

@fylyppo fylyppo self-assigned this May 21, 2024
@fylyppo
Copy link
Collaborator

fylyppo commented May 21, 2024

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.

@DimitarStoyanov91
Copy link
Author

@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.

@b055man
Copy link

b055man commented May 29, 2024

@DimitarStoyanov91 any chance it is related to this: #2111 (comment) ?

@DimitarStoyanov91
Copy link
Author

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."

@fylyppo fylyppo added bug Something isn't working platform: android Android is affected package: patrol Related to the patrol package (native automation, test bundling) P2 Issues not at the top of the work list labels Jul 17, 2024
@fylyppo fylyppo removed their assignment Jul 17, 2024
@ahlstro
Copy link
Contributor

ahlstro commented Sep 18, 2024

Have the same problem. Got 3 solutions atm in my tests code.

  1. Open and close notifications (native)
  2. Scroll to the widget (use scrollTo)
  3. Use enterText directly into the finder without tapping the textField widget

Would very much like a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Issues not at the top of the work list package: patrol Related to the patrol package (native automation, test bundling) platform: android Android is affected
Projects
None yet
Development

No branches or pull requests

4 participants