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

Webview interaction - selecting correct element when Selector applies to multiple elements #663

Closed
PiotrMitkowski opened this issue Dec 5, 2022 · 8 comments · Fixed by #849, #952 or #1569
Labels
bug Something isn't working platform: ios iOS is affected
Milestone

Comments

@PiotrMitkowski
Copy link
Contributor

Let's assume the following login form:
Zrzut ekranu 2022-12-5 o 13 02 44

My app opens it in a web view, and I want to put some login and password and tap the "Log in" button. I use the following code:

await $.native.enterTextByIndex('some_login', index: 0);
await $.native.enterTextByIndex('some_password', index: 1);
await $.native.tap(Selector(text: 'Log in'));

Entering the text works like a charm, but the tap() command selects the header above the fields instead of the button. I tried with className: 'button', 'className: 'Button' (inspired by the article on Medium), but it couldn't find such element. I also tried playing with the instance field, but I only got IllegalArgumentException with a message saying, that instance isn't supported.

Is there a way to select the button in such case?

@bartekpacia bartekpacia added bug Something isn't working platform: android Android is affected labels Dec 5, 2022
@bartekpacia
Copy link
Contributor

bartekpacia commented Dec 5, 2022

Hi again :)

You've hit quite an ugly corner case, which I also don't like. But before I start complaining on Android's crippled UI selectors in tests, please try with className: 'android.widget.Button' instead of className: 'button' and let me know if it helps. It would also help if you did a native view hierarchy dump and shared it here (or at least part of it, if you're under some NDA)

@PiotrMitkowski
Copy link
Contributor Author

'android.widget.Button' worked like a charm, thanks! Do you still want to see the native view hierarchy?

@bartekpacia
Copy link
Contributor

bartekpacia commented Dec 5, 2022

I'm happy that you solved it :)

Do you still want to see the native view hierarchy?

No, not needed anymore.

But if you had two Button widgets with text "Log in", then this wouldn't be possible to do in Patrol. I'll keep this issue open until I find a nice fix.

@bartekpacia
Copy link
Contributor

@PiotrMitkowski I implemented this feature in #849 :)

Screen.Recording.2023-01-30.at.12.23.04.AM.mov

@PiotrMitkowski
Copy link
Contributor Author

@bartekpacia wow, nice! You're doing a great job here, thanks 🙂

@bartekpacia bartekpacia reopened this Feb 16, 2023
@bartekpacia
Copy link
Contributor

Android is done, iOS todo.

@bartekpacia
Copy link
Contributor

bartekpacia commented Mar 5, 2023

iOS was done in #952, but it got reverted in #1042.

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.