2014-03-12 21 views
2

使用uiautomator測試Android應用程序UI行爲時,會指示它確保可以訪問UI。 Ït在文檔中聲明「應該使用android:提示來代替EditText字段的內容描述」。 (http://developer.android.com/tools/testing/testing_ui.html#accessibility使用uiautomator時,爲什麼應該使用提示來代替EditText的contentDescription?

這是爲什麼?如果還添加了內容描述,是否還有一些缺點?

當僅使用android:hint與android:inputType =「textPassword」時,EditText仍爲NAF(不可訪問)。但是當添加contentDescription時,EditText是可訪問的。

另外,resource-id是一個可用於在使用uiautomator測試UI時引用的屬性嗎?

在此先感謝。

回答

1

您可以同時使用content-description和提示。

資源ID也是訪問由於Android API級別已添加的元素是非常有用的18

它可以作爲使用:

UiObject psswrd = new UiObject(new UiSelector().resourceId("com.example.abc:id/password")); 
psswrd.click(); 
psswrd.setText("qwerty"); 
+0

謝謝您的回答。我想我會用資源ID去。遺憾的是文檔在這裏有點模糊。 – TuomasG

+0

不適合我。 我hv最新的API 19和Android L. 它打開鍵盤,但不寫入edittext。 – DearDhruv

+0

_ + 1_它適用於我的Android 6.0.1,Nexus 5 – nAkhmedov

相關問題