簡體   English   中英

使用Robotium進行android和測試,如何在片段中選擇listView的一個元素?

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

在使用Robotium進行測試時,如何在片段中選擇listView的元素? 我在布局中有2個片段容器:

>     <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"
>          .../>
>     />

並使用以下代碼加載每個片段:

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

我的測試如下:

@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);               
 ... }

問題是solo.clickInList(0),總是被點擊屬於右邊負載片段的Lis​​tView元素。 怎么做“solo.clickInList()”點擊左邊的列表這里的圖像

有一個solo.clickInList(0, integer); 它允許您指定要單擊的列表。 你試過嗎? 您還可以單擊特定文本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM