edudepetris
edudepetris

Reputation: 714

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 ??

Upvotes: 0

Views: 3318

Answers (1)

dmon
dmon

Reputation: 30168

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.

Upvotes: 2

Related Questions