我有一个机器人脚本来指导机器人测试实验室。但是在自动测试执行单击单选按钮时总是会出错
我读取action.json,logcat并从测试结果中观看视频。它告诉我机器人测试可以从27开始通过24步
来自测试结果中的actions.json
{
"sequence": 29,
"sourceScreenId": "14",
"destinationScreenId": "14",
"startTimeSeconds": 81.355,
"endTimeSeconds": 81.442,
"executionResult": "FAILED",
"isRoboscriptActive": true,
"target": {
"type": "TAP",
"childSequence": "0.0.1.0.1.0.0.0.1.0.2.0.6",
"targetDetails": {
"componentType": "BUTTON",
"resourceName": "id.tumbasin.app.debug:id/radioBankTransfer",
"className": "androidx.appcompat.widget.AppCompatRadioButton",
"androidClassName": "android.widget.RadioButton"
}
}
}, {
"startTimeSeconds": 81.442,
"endTimeSeconds": 81.442,
"roboscriptFinished": {
"reason": "ACTION_FAILED"
}
}
机器人脚本
{
"eventType": "VIEW_CLICKED",
"timestamp": 1571809883185,
"replacementText": "",
"actionCode": -1,
"delayTime": 0,
"canScrollTo": false,
"elementDescriptors": [
{
"className": "androidx.appcompat.widget.AppCompatRadioButton",
"recyclerViewChildPosition": -1,
"adapterViewChildPosition": -1,
"groupViewChildPosition": 6,
"resourceId": "id.tumbasin.app.debug:id/radioBankTransfer",
"contentDescription": "",
"text": ""
},
{
"className": "androidx.constraintlayout.widget.ConstraintLayout",
"recyclerViewChildPosition": -1,
"adapterViewChildPosition": -1,
"groupViewChildPosition": 0,
"resourceId": "",
"contentDescription": "",
"text": ""
},
{
"className": "androidx.cardview.widget.CardView",
"recyclerViewChildPosition": -1,
"adapterViewChildPosition": -1,
"groupViewChildPosition": 2,
"resourceId": "id.tumbasin.app.debug:id/cardPayment",
"contentDescription": "",
"text": ""
}
]
},
来自logcat
Caused by: androidx.test.espresso.PerformException: Error performing 'single click' on view '(with class name: is "androidx.appcompat.widget.AppCompatRadioButton" and with id: id.tumbasin.app.debug:id/radioBankTransfer and is a child at 6th index of the matching parent: (with class name: is "androidx.constraintlayout.widget.ConstraintLayout" and with id: 1 (resource name not found) and is a child at 0th index of the matching parent: (with class name: is "androidx.cardview.widget.CardView" and with id: id.tumbasin.app.debug:id/cardPayment and is a child at 2th index of the matching parent: (with class name: is "androidx.constraintlayout.widget.ConstraintLayout" and with id: 1 (resource name not found) and is a child at 0th index of the matching parent: (with class name: is "androidx.core.widget.NestedScrollView" and with id: id.tumbasin.app.debug:id/scrollViewOrder and is a child at 1th index of the matching parent: (with class name: is "androidx.constraintlayout.widget.ConstraintLayout" and with id: 1 (resource name not found) and is a child at 0th index of the matching parent: (with class name: is "android.widget.FrameLayout" and with id: id.tumbasin.app.debug:id/nav_host_fragment and is a child at 0th index of the matching parent: (with class name: is "androidx.constraintlayout.widget.ConstraintLayout" and with id: id.tumbasin.app.debug:id/container and is a child at 0th index of the matching parent: (with class name: is "androidx.appcompat.widget.ContentFrameLayout" and with id: android:id/content and is a child at 1th index of the matching parent: (with class name: is "androidx.appcompat.widget.FitWindowsLinearLayout" and with id: id.tumbasin.app.debug:id/action_bar_root and is a child at 0th index of the matching parent: (with class name: is "android.widget.FrameLayout" and with id: 1 (resource name not found) and is a child at 1th index of the matching parent: (with class name: is "android.widget.LinearLayout" and with id: 1 (resource name not found) and is a child at 0th index of the matching parent: (with class name: is "com.android.internal.policy.DecorView" and with id: 1 (resource name not found) and is a root view.)))))))))))))'.
答案 0 :(得分:0)
看起来Robo正确找到了要执行点击操作的元素,但是在Espresso本身内部点击失败。需要更多的上下文信息来理解Espresso为什么无法单击此单选按钮,例如单选按钮是否完全可见等。日志中是否还有其他与此异常相关的内容,可能会使根源更加明了问题的原因?
此外,您可以使用Android Studio中的Espresso Test Recorder(运行|记录Espresso测试)来记录与您为Roboscript录制的动作完全相同的Espresso测试。然后,通过运行此Espresso测试,您可以检查同一操作是否失败,如果失败,则错误消息将包含更多上下文信息。