Frage

When using uiautomator to test Android application UI behavior, it's instructed to ensure that UI is accessible. Ït is stated in documentation that "android:hint should be used instead of content description for EditText fields". (http://developer.android.com/tools/testing/testing_ui.html#accessibility)

Why is this? Is there some disadvantage if content description is also added?

When using only android:hint with android:inputType="textPassword", the EditText remains NAF (not accessible). But when adding contentDescription, the EditText is accessible.

Also, is resource-id an attribute that could be used to reference when using uiautomator to test UI?

Thanks in advance.

War es hilfreich?

Lösung

You can use both content-description and hint.

Resource id is also very useful in accessing elements which has been added since Android API Level 18.

It can be used as :

UiObject psswrd = new UiObject(new UiSelector().resourceId("com.example.abc:id/password")); 
psswrd.click();
psswrd.setText("qwerty");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top