1
RecylerView包含一個TextView在last.I「一些內容」我不能我recylerview滾動到最後一個文本是shown.I都想盡命中和試驗方法發現給我,但無法找到任何解決方案。我曾嘗試RecylerView不滾動到android系統測試用例最後文本與咖啡
代碼: -
1. onView(withId(R.id.recylerview)).perform(scrollToPosition(13));
//my last text view in recyler view is at position 13
2.onView(withText("Some content")).perform(scrollTo(), click());
//my text is "Some content"
我的問題是,作爲回收視圖包含所有13個items.As我已經設置文本編程值相同的文本視圖,我不能ID搜索。
所以這個代碼不能申請: -
onView(withId(R.id.txtview)).perform(scrollTo(), click());
EspressoCode
UiObject2 button9 = device.findObject(By.text("S 5 [None]"));
button9.click();
try {
UiObject srText = new UiObject(new UiSelector().resourceId("com.example.project:id/radio"));
sText.click();
}catch(Exception e){
}
onView(withRecyclerView(R.id.recylerview).atPosition(13))
.check(matches((hasDescendant(withText("Some content")))));
UiObject2 button10 = device.findObject(By.text("S 6 [None]"));
button10.click();
try {
UiObject sensorText = new UiObject(new UiSelector().resourceId("com.example.project:id/radio"));
sensorText.click();
}catch(Exception e){
}
嘿,我有試圖實現這一點,但用RecyclerView和atPosition方法顯示無法解析方法。 –
所以你基本上需要RecyclerViewMatcher文件(文件)在您的androidTest/JAVA/blahblah文件夾。然後,在實際的espresso測試中,您需要添加withRecyclerView靜態方法,就是這樣。 atPosition方法是RecyclerViewMatcher中的一個公共方法,所以一旦你有權訪問它,它應該沒問題。 –
是的,我已經實現,但在調試器到達的,應用靠攏與工藝的簡歷仍然沒有working.and。 –