我希望有人可以帮助我解决这个问题,在 ddms 层次结构中如下:
(0) ListView
(0) LinearLayout
(0) LinearLayout
(0)TextView:Value 1
(1)TextView:Value 2
(2)TextView:Value 3
(1)View
(2) LinearLayout
(1) LinearLayout
(0) LinearLayout
(0)TextView:Value 4
(1)TextView:Value 5
(2)TextView:Value 6
(1)View
(2) LinearLayout
我试图做的是使用机器人来确认文本视图中的值。我的问题是第二组视图具有相同的资源 ID,例如值 1 和值 4 的资源 ID 均为 com.myapp.this:id/TopEntry
有没有办法使用robotium逐步定位视图,即获取视图0、1、0等。
目前我检查视图内容的代码是:
public String checkView(String theview, String expected)
{
string actual = "";
string result = "";
TextView view = (TextView) solo.getView(theview);
actual = (String) view.getText();
assertEquals("viewChecked",expected,actual);
--------- code continues ---------------
}
因此,对于我的示例,我将使用以下方法调用代码:
checkView("TopEntry","Value 1");
checkView("TopEntry","Value 4"); <---------------and heeeeers the problem