java - .getCurrentListViews() 方法在 Robotium 中不可用于迭代列表 TextView 。

标签 java android unit-testing listview robotium

我想通过此文档 http://controlingquality.blogspot.in/2011/08/playing-with-android-application.html 访问 Robotium 测试类中的 ListView 子 TextView 值我看到这些行来访问 TextView ListView lvResults = solo.getCurrentListViews().get(0);ArrayList vTextViewResults = solo.getCurrentTextViews(lvResults); 第一行获取屏幕上使用的第一个列表,第二行获取 ArrayList 中的所有 TextView 控件,但缺少 .getCurrentListViews() 方法。我使用的版本 robotium:robotium-solo:5.5.2

还引用了一些链接Iterating through a List and clicking on list items in Robotium https://groups.google.com/forum/#!topic/robotium-developers/UY69TKCF5Fw

最佳答案

上网查了一下才知道,从4.0开始(不确定具体是哪个版本),有些方法被泛型方法取代了。

上一个代码,用于获取屏幕上使用的第一个列表

ListView list = solo.getCurrentListViews().get(0);

现在要在更新库中获得相同的内容,应该是

ListView list = solo.getCurrentViews(ListView.class).get(0);

因此,对于列表 TextView 中的迭代,它应该是

//TODO: Getting all TextView in the List
 for (TextView txt : solo.getCurrentViews(TextView.class, solo.getCurrentViews(ListView.class).get(0))) {
        Log.i("ListItem", txt.getText().toString());

    }

有帮助Link

关于java - .getCurrentListViews() 方法在 Robotium 中不可用于迭代列表 TextView 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34028325/

相关文章:

java - 计算网络下载速度

android - LiveData 不会将类型推断为所需的返回值

c# - (Unity 2D)在离开屏幕时销毁实例化的预制件?

unit-testing - 基于部分单元测试的软件方法

c# - 隐式运行单元测试

java - typescript 编译(就Java编译而言)

java - 在 Servlet 请求中创建到 SQL Server 数据库的连接 Thows "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver"

javascript - 检查子组件是否呈现 - Jest, Enzyme

java - 打印存储类的链表时出现问题

android - 如何使用 gradle 将 Reflections 库集成到 android studio 中并保存和收集