简体   繁体   中英

android & testing with Robotium, how select a element of the listView in fragment?

In testing with Robotium, how select a element of the listView in fragment ? I have 2 fragment Container in layout :

>     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
>      ... 
>         <FrameLayout
>             xmlns:android="http://schemas.android.com/apk/res/android"
>             android:id="@+id/fragment_container_left"
>         ... />
>         <FrameLayout
>             xmlns:android="http://schemas.android.com/apk/res/android"
>             android:id="@+id/fragment_container_rigth"
>          .../>
>     />

and each fragment are load with the following code :

> <ListView
>     android:id="@+id/listView1" 
>  ... />

and my testing is the following :

@Override
protected void setUp() throws Exception {
    super.setUp();
    mActivity = getActivity();
    mIns = this.getInstrumentation();
    solo = new Solo(mIns, mActivity);
}
public void testBackButton() {

      // click in listView
      solo.clickInList(0);
      solo.clickInList(0);               
 ... }

the problem is that solo.clickInList(0), always being done click the ListView element belonging to the fragment on the right laden. how do to "solo.clickInList()" click the list on the left here image ??

There's a solo.clickInList(0, integer); that lets you specify which list to click. Did you try that? You can also click on a specific text.

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