-
Notifications
You must be signed in to change notification settings - Fork 156
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
Entering text in webview doesn't work #922
Comments
Hi 👋 Did you specify the bundle ID of your app in |
Yes i did in the pubspec.yml
|
Ah i see you are corrrect. it was building |
@bartekpacia Sorry to keep bugging you it seems it only entered the text that one time. I am unable to enter the text again i have no idea why.
when i do flutter logs i see
My code is
Ive tried adding
But it doesnt find the field and errors there. The form is I feel like this is something to do with using flavors. Once i get past the webview I can send you a tip for the help if you send me a link. |
Thanks for all the details. I'll try to reproduce and fix the issue tomorrow.
I work full-time at @leancodepl on this library, and I'm compensated well :) Thank you, though - this is very kind of you. |
Great let me know if you need more info. That is good to hear always good to get paid for working ha |
after changing my entitlements to
Now it looks like it's at least trying to do it. |
more logs
|
Nope i played with that as well both are now Debug and still same issue. Ill update if i have anything else, i havent made any progress yet. |
Ok @bartekpacia there was an issue with flutter onError not being restored
This outputs a nice patrol error now
In a later test you see the same output as before
So for some reason this error only triggers on the first test, after that it bypasses this error and gives a less readable error |
The webview widget is
So it looks like it's just erroring on the input when the keyboard show up? |
I investigated this issue a bit and I'm pretty sure that it comes down to the website being Not Accessibility Friendly. After going to the webview and taking a native view hierarchy dump, I saw:
and
What's important is Apparently, UIAutomator cannot perform actions on NAF views, even when I'd expect that it should be able to perform them. For example I tried: await $.native.enterText(
Selector(resourceId: 'user_email'),
text: 'charlie@root.me',
);
await $.native.enterText(
Selector(resourceId: 'user_password'),
text: 'ny4ncat',
);
await $.native.tap(Selector(text: 'Log in')); and it doesn't work (output from
In an act of despair, I also tried listing: final views = await $.native.getNativeViews(Selector(className: 'android.widget.EditText'));
print("${views.length} views found")
for (final view in views) {
print('view: $view');
} and it finds 0 views, while I'd expect 2 to show up (login and password). So the solution I'd suggest trying out is to make changes to the sign-in website to add "content-description" for accessibility tools so that it won't appear as Not Accessibility Friendly. See also: Here's the test code and webview screen code that I tried (a slightly modified example app) |
I managed to get the test to pass on iOS: record.movFull code is in #938 - let me know if it works if you Unfortunately, the code that does it is very ugly (because of hardcoded screen refreshing (a.k.a pumping)): import 'common.dart';
Future<void> main() async {
testWebViewA();
}
void testWebViewA() {
patrol('interacts with the LeanCode website in a webview', ($) async {
await $.pumpWidgetAndSettle(ExampleApp());
await $('Open webview screen A').scrollTo().tap();
// this is a very ugly anti-pattern in tests
for (var i = 0; i < 300; i++) {
await $.pump();
}
await $.native.enterTextByIndex(
'barpac02@gmail.com',
index: 0,
);
await $.native.enterTextByIndex(
'ny4ncat',
index: 1,
);
await $.native.tap(Selector(text: 'Log in'));
});
} If I remove the pumping for 300 iterations, I'm getting:
There are 2 solutions:
What do you think? |
Ok its not entering text after i remove all the pumpAndSettle's
Now its not closing the dialog and adding a "q" at the end of the email for some reason.
just double checked landscape isnt broken in the app ha |
What dialog?
Wow, this is sooo weird. Doesn't occur on my machine.
Yeah. I think adding the timeout to |
I think it's because you're in landscape mode. After Patrol enters the email into the first text field, it taps on the second text field to enter the password. But, the keyboard is obscuring the second text field, so Patrol taps on the keyboard, specifically on the That's just my guess. Try portrait mode and let me know if the issue persists. |
Is there a way to force run in portrait? Something like
For the patrol cli? |
after changing to only portrait it started working. |
Portrait/landscape mode is a setting belonging to the iOS Simulator app, you should change it there. Maybe you have your Simulator set to run by default in landscape mode? I don't know, really. |
In the file RunnerUILaunchTests it contains
which looks like its doing it. Back to the webview now its entering text however the login button isnt being pressed
I think the keyboard is covering up the button is there a way to manually close the keyboard? |
adding Now the output is
|
Delete this file – it's not needed.
That's because you've got 2 "Log in" texts - the first one is the heading, and the second one is on the button. This should be possible to do with: await $.native.tap(
Selector(
text: 'Log in',
instance: 1,
),
); Unfortunately it isn't, but I see this is very important. Going to fix it as part of #663. |
Ok deleting that file was a good idea, now its running the tests once instead of multiple time with different orientations and dark mode/light mode. Great thanks for working on that already. |
|
import 'common.dart';
Future<void> main() async {
testWebViewD();
}
void testWebViewD() {
patrol('interacts with the login form website in a webview', ($) async {
await $.pumpWidgetAndSettle(ExampleApp());
await $('Open webview (login form)').scrollTo().tap();
await $.native.enterTextByIndex('test@hey.com', index: 0);
await $.native.enterTextByIndex('some pass', index: 1);
await $.native.tap(Selector(text: 'Sign in'));
});
} This reliably works on my iPhone 14 simulator (I'm using Screen.Recording.2023-02-17.at.11.31.29.AM.mov |
Ok finally got it flutter integration tests really deosnt like it when you overwrite onError. If you do you need to wrap your app in
I thought wrapping the app with restoreFlutterError would wrap all errors however anytime there is an error the app will break if you dont wrap that call in thanks for all your help closing this now. |
Thanks a lot, we'll be playing with |
Doing this is better
The other way will load the app but will error out on the expect(). |
This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. |
Describe the bug
Using https://joyful-noise-staging.joyful-noise.link/users/sign_in as a form
I have tried the way mentioned in the docs
Nothing shows in form.
To Reproduce
Steps to reproduce the behavior:
1.Use https://joyful-noise-staging.joyful-noise.link/users/sign_in as base url
2. try to enter text in form and submit
3. App hangs with no error
Expected behavior
A clear and concise description of what you expected to happen.
Device information
Device: iPhone14
Does it also both on physical and virtual devices? [didn't check]
Additional information
flutter --version
Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9944297138 (5 days ago) • 2023-02-08 15:46:04 -0800
Engine • revision 248290d6d5
Tools • Dart 2.19.2 • DevTools 2.20.1
patrol: ^0.10.12
patrol_cli v0.9.4
Additional context
The text was updated successfully, but these errors were encountered: