Robotium:如何在RecyclerView行中自动点击按钮?

时间:2016-02-10 12:31:50

标签: android automated-tests android-recyclerview robotium

我正在使用 Robotium (版本:5.5.3)。我在RecyclerView的行中有一个按钮。我想自动点击特定行上的那个按钮。

solo.clickInRecyclerView(index);  only automates the clicking of that whole row.

我该怎么做?

1 个答案:

答案 0 :(得分:0)

getActivity().getFragmentManager().getFragmentAtPosition(count-1)

这将为您提供最顶层(当前)片段。 然后将其投入所需的碎片。例如

MyFrag myCurrentFrag = (MyFrag) ....

然后使用它,获取适配器或recylerview。 获得所需的recylerview实例后,请使用

RelativeLayout myRel = (RelativeLayout) getchildAt();
Button btn = (button) myRel.findViewById();
btn.performClick();