MobileFirst Test Workbench 测试执行期间出现 ClassCastException
MobileFirst Test Workbench ClassCastException during test execution
MobileFirst 测试 Workbench 8.7(包含在 MobileFirst Platform 7.0 中)
测试设备:android 4.4.2
测试应用:原生应用
Android SDK 工具:23.0.2
Android SDK 平台工具:20
Android SDK 构建工具:19.1
测试执行时,listView元素点击事件后报如下异常。
记录测试用例时未报告此错误。
Exception thrown: ClassCastException: android.widget.ListView cannot be cast to android.widget.RelativeLayout
at com.xx.yy.CatalNavFragment.onItemClick(CatalNavFragment.java:267)
at android.widget.AdapterView.performItemClick(AdapterView.java:308)
at android.widget.AbsListView.performItemClick(AbsListView.java:1478)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.actions.Action_itemclickposition.performAction(Action_itemclickposition.java:40)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.actions.Action.performAction(Action.java:101)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.ATestStep.run(ATestStep.java:502)
at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at dalvik.system.NativeStart.main(Native Method)
引发异常的代码:
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
ContentValues niveau = (ContentValues) catalNavAdapter
.getItem(position);
id_niveau = niveau.getAsString(CatalProvider.KEY_ID);
Long niveau_usg = niveau.getAsLong(CatalProvider.KEY_NIVEAU);
RelativeLayout rlyt = (RelativeLayout) view; //!! EXCEPTION IS RAISED HERE
TextView txtLibelle = (TextView) rlyt.getChildAt(0);
Bundle i = new Bundle();
if (niveau_usg > 0) {
String subcategory = txtLibelle.getText().toString();
CatalProdFragment CPF = new CatalProdFragment();
i.putString("id_niveau", id_niveau);
i.putLong("niveau_usg", niveau_usg);
i.putString("subcategory", subcategory);
i.putString("category", extras.getString("category"));
CPF.setArguments(i);
TabHolderFragmentActivity.getMainScreenActivity().pushFragments(parentTab, CPF, CPF
.getClass().getSimpleName(), true, true);
} else {
CatalNavFragment CNF = new CatalNavFragment();
i.putString("id_niveau", id_niveau);
i.putString("category", catalNavAdapter.getData().get(position)
.getAsString("libelle"));// category);
CNF.setArguments(i);
TabHolderFragmentActivity.getMainScreenActivity().pushFragments(parentTab, CNF, CNF
.getClass().getSimpleName(), true, true);
}
setExitPageBoolean(false);
}
列表视图布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/catalpage"
android:background="@color/greybg" >
<include
android:id="@+id/include_conatiner"
layout="@layout/produits_container" />
<TextView
android:id="@+id/catal_list_title"
style="@style/screenHeader"
android:layout_below="@id/include_conatiner"
android:layout_marginBottom="15dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="@string/produits_header"
android:visibility="gone" />
<ListView
android:id="@android:id/list"
style="@style/catal_list"
android:layout_below="@+id/catal_list_title" />
<TextView
android:id="@id/android:empty"
style="@style/texte.error"
android:layout_below="@+id/catal_list_title" />
</RelativeLayout>
列表视图项目布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlyt_cat_nav_item"
style="@style/catal_list_item" >
<TextView
android:id="@+id/catal_nav_libelle"
style="@style/texte.titre.center"
android:layout_width="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="#000000" />
<TextView
android:id="@+id/catal_nav_count_libelle"
style="@style/texte_parent_right"
android:padding="5dp"
android:textColor="#000000" />
<TextView
android:id="@+id/catal_nav_id_niveau"
style="@style/hidden" />
</RelativeLayout>
感谢您的帮助
马修
问题来自 rtw 8.7 和旧版本中的一个小错误
(简而言之,传递给侦听器的某些参数是错误的。位置没问题,视图不是)
联系我们的 8.7 修补程序支持,或等待包含它的 8.7.0.1(应该很快可用)
杰罗姆·博齐尔
高级软件工程师
android
的 IMB RTW 手机
MobileFirst 测试 Workbench 8.7(包含在 MobileFirst Platform 7.0 中) 测试设备:android 4.4.2 测试应用:原生应用 Android SDK 工具:23.0.2 Android SDK 平台工具:20 Android SDK 构建工具:19.1
测试执行时,listView元素点击事件后报如下异常。 记录测试用例时未报告此错误。
Exception thrown: ClassCastException: android.widget.ListView cannot be cast to android.widget.RelativeLayout
at com.xx.yy.CatalNavFragment.onItemClick(CatalNavFragment.java:267)
at android.widget.AdapterView.performItemClick(AdapterView.java:308)
at android.widget.AbsListView.performItemClick(AbsListView.java:1478)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.actions.Action_itemclickposition.performAction(Action_itemclickposition.java:40)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.actions.Action.performAction(Action.java:101)
at com.ibm.rational.test.mobile.android.runtime.playback.engine.ATestStep.run(ATestStep.java:502)
at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) at dalvik.system.NativeStart.main(Native Method)
引发异常的代码:
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
ContentValues niveau = (ContentValues) catalNavAdapter
.getItem(position);
id_niveau = niveau.getAsString(CatalProvider.KEY_ID);
Long niveau_usg = niveau.getAsLong(CatalProvider.KEY_NIVEAU);
RelativeLayout rlyt = (RelativeLayout) view; //!! EXCEPTION IS RAISED HERE
TextView txtLibelle = (TextView) rlyt.getChildAt(0);
Bundle i = new Bundle();
if (niveau_usg > 0) {
String subcategory = txtLibelle.getText().toString();
CatalProdFragment CPF = new CatalProdFragment();
i.putString("id_niveau", id_niveau);
i.putLong("niveau_usg", niveau_usg);
i.putString("subcategory", subcategory);
i.putString("category", extras.getString("category"));
CPF.setArguments(i);
TabHolderFragmentActivity.getMainScreenActivity().pushFragments(parentTab, CPF, CPF
.getClass().getSimpleName(), true, true);
} else {
CatalNavFragment CNF = new CatalNavFragment();
i.putString("id_niveau", id_niveau);
i.putString("category", catalNavAdapter.getData().get(position)
.getAsString("libelle"));// category);
CNF.setArguments(i);
TabHolderFragmentActivity.getMainScreenActivity().pushFragments(parentTab, CNF, CNF
.getClass().getSimpleName(), true, true);
}
setExitPageBoolean(false);
}
列表视图布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/catalpage"
android:background="@color/greybg" >
<include
android:id="@+id/include_conatiner"
layout="@layout/produits_container" />
<TextView
android:id="@+id/catal_list_title"
style="@style/screenHeader"
android:layout_below="@id/include_conatiner"
android:layout_marginBottom="15dp"
android:layout_marginLeft="5dp"
android:gravity="center_vertical"
android:text="@string/produits_header"
android:visibility="gone" />
<ListView
android:id="@android:id/list"
style="@style/catal_list"
android:layout_below="@+id/catal_list_title" />
<TextView
android:id="@id/android:empty"
style="@style/texte.error"
android:layout_below="@+id/catal_list_title" />
</RelativeLayout>
列表视图项目布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlyt_cat_nav_item"
style="@style/catal_list_item" >
<TextView
android:id="@+id/catal_nav_libelle"
style="@style/texte.titre.center"
android:layout_width="wrap_content"
android:layout_marginLeft="5dp"
android:textColor="#000000" />
<TextView
android:id="@+id/catal_nav_count_libelle"
style="@style/texte_parent_right"
android:padding="5dp"
android:textColor="#000000" />
<TextView
android:id="@+id/catal_nav_id_niveau"
style="@style/hidden" />
</RelativeLayout>
感谢您的帮助
马修
问题来自 rtw 8.7 和旧版本中的一个小错误 (简而言之,传递给侦听器的某些参数是错误的。位置没问题,视图不是) 联系我们的 8.7 修补程序支持,或等待包含它的 8.7.0.1(应该很快可用)
杰罗姆·博齐尔 高级软件工程师 android
的 IMB RTW 手机