gpt4 book ai didi

android - 使用uiautomator时,为什么要使用hint而不是EditText的contentDescription?

转载 作者:行者123 更新时间:2023-11-29 01:44:23 24 4
gpt4 key购买 nike

当使用 uiautomator 测试 Android 应用程序 UI 行为时,它被指示确保 UI 可访问。 Ït 在文档中声明“应该使用 android:hint 而不是 EditText 字段的内容描述”。( http://developer.android.com/tools/testing/testing_ui.html#accessibility )

这是为什么?加上内容描述会不会有什么弊端?

当仅使用 android:hint 和 android:inputType="textPassword"时,EditText 仍然是 NAF(不可访问)。但是当添加 contentDescription 时,EditText 是可以访问的。

还有,resource-id是不是一个属性,在使用uiautomator测试UI时可以用来引用?

提前致谢。

最佳答案

您可以同时使用内容描述和提示。

资源 ID 在访问自 Android API 级别 18 以来添加的元素时也非常有用。

它可以用作:

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

关于android - 使用uiautomator时,为什么要使用hint而不是EditText的contentDescription?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22346116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com