简体   繁体   中英

Robotium: How to automate button click in the RecyclerView row?

I am using Robotium (Version: 5.5.3). I have a button in the row of RecyclerView. I want to automate the clicking of that button on a specific row.

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

How can I do this?

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

This would give you the topmost (current) fragment. Then cast it into the desired fragmnet. eg.

MyFrag myCurrentFrag = (MyFrag) ....

Then using it, get the adapter or recylerview. Once you have the desired recylerview instance, make use of

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM