如何使用appium在Android应用中获取内容描述 [英] How to get content-desc in Android app using appium
本文介绍了如何使用appium在Android应用中获取内容描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为Android应用编写自动化测试.
I am writing automation test for Android app.
当我尝试获取文章标题的content-desc时.我无法获取它.
When I am trying to get content-desc for article title. I am not able to fetch it.
仅供参考,我没有文字.
FYI I don't have text.
List<WebElement> arrayOfProperties2 = driver.findElementsByClassName("android.view.View");
for (WebElement property : arrayOfProperties2){
System.out.println("property" + property.getClass());
String contentDesc = property.getAttribute("name");
String contentDesc1 = property.getAttribute("className");
String contentDesc2 = property.getAttribute("resourceId");
System.out.println("contentDesc" + contentDesc);
System.out.println("contentDesc1" + contentDesc1);
System.out.println("contentDesc2" + contentDesc2);
}
结果:-
contentDesc
contentDesc1android.view.View
contentDesc2
推荐答案
与UI automator2配合使用:
Using it with UI automator2:
element.getAttribute("contentDescription")
这篇关于如何使用appium在Android应用中获取内容描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文