gpt4 book ai didi

java - Robotium:有没有办法列出屏幕/Activity 上所有元素的标签/ID?

转载 作者:太空狗 更新时间:2023-10-29 16:41:39 24 4
gpt4 key购买 nike

非常不言自明。假设我有一个登录屏幕,但我不知道开发人员(我是 QA)将用户名和密码文本字段命名为什么。鉴于我们的应用程序中有数百个此类字段,我不想每次需要此信息时都打扰他。

是否有某种方式以编程方式列出 Activity 屏幕上所有元素的标签或 ID?

谢谢。

最佳答案

获取浏览量

是的,您可以将 solo.getCurrentViews() 用于该方法或任何更具体的方法。从 api 看:

http://www.jarvana.com/jarvana/view/com/jayway/android/robotium/robotium-solo/3.1/robotium-solo-3.1-javadoc.jar!/com/jayway/android/robotium/solo/Solo.html#getCurrentViews()

编辑:找到最新文档:http://robotium.googlecode.com/svn/doc/index.html

getCurrentViews

public ArrayList getCurrentViews() Returns an ArrayList of the View objects currently shown in the focused Activity or Dialog. Returns: an ArrayList of the View objects currently shown in the focused window

迭代 View (完整代码示例)

for( View v : solo.getCurrentViews()){
// do something with the View object here
int viewId = v.getId();
}

http://developer.android.com/reference/android/view/View.html

关于java - Robotium:有没有办法列出屏幕/Activity 上所有元素的标签/ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16823328/

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