nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
216 stars 80 forks source link

MDTextField cannot be found by its testID attribute on Android #460

Closed volkanatalan closed 6 months ago

volkanatalan commented 6 months ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

1- Add an MDTextField component to the page with a testID attribute

<MDTextField text="text" testID="text-field" />

2- Run maestro studio and do assertVisible for the "text-field" id

- assertVisible:
    id: "text-field"

It returns false for the assertion on Android. However it works fine on iOS.

farfromrefug commented 6 months ago

@volkanatalan could you share a simple repro example. I think i know what the issue is but i would need to reproduce it

volkanatalan commented 6 months ago

@farfromrefug Thank you for your interest. Here it is:

https://github.com/volkanatalan/MDTextFieldTestIdIssue

I added both MDTextField and TextField components to the page. I can find TextField with its testID but can't find MDTextField.

farfromrefug commented 6 months ago

@volkanatalan thanks but it is missing the maestro part isnt it? I never used maestro so would be nice for the sample project to have it set up

volkanatalan commented 6 months ago

@farfromrefug To install Maestro you need to run the following command:

curl -Ls "https://get.maestro.mobile.dev" | bash

I think this will be enough to install it, but if you need any further information, you can check the Maestro documentation.

Then you need to run Maestro Studio with the following command from the terminal:

maestro studio

This will open a page in the browser, similar to this:

Screenshot 2024-03-28 at 13 41 53

If you click on the text fields, you will see the suggestions (tap, assert etc.). You will notice that it gives the suggestions with an "id" for the component on the bottom (TextField) but not for the component on the top (MDTextField).

farfromrefug commented 6 months ago

@volkanatalan i just released a new version which should fix this!

volkanatalan commented 6 months ago

Awesome thanks @farfromrefug

volkanatalan commented 6 months ago

@farfromrefug I installed the latest version but the issue still persists.

https://github.com/nativescript-community/ui-material-components/blob/0f2ce73a0a505ab07f65ce88e1b8263e78271d6b/src/textfield/textfield.android.ts#L338

https://github.com/nativescript-community/ui-material-components/blob/0f2ce73a0a505ab07f65ce88e1b8263e78271d6b/src/textfield/textfield.android.ts#L342

I think this.nativeViewProtected should be passed to setAccessibilityIdentifier instead of this.nativeTextViewProtected. When I do this change, I can find the component.

farfromrefug commented 6 months ago

@volkanatalan damn what did i do :D Indeed my commit is wrong!

farfromrefug commented 6 months ago

@volkanatalan new release up. Hopefully this one is good

volkanatalan commented 6 months ago

@farfromrefug haha no worries now it works like a charm. Thank you very very much 👍 👍