Search code examples
androidfirebase-test-lab

How to solve Robo test failed when it try to click Radio Button?


I have a robo script to guide robo test lab. But always get error when robo test perform click to radio button

i read action.json, logcat, and watch video from test result. it show me that robo test can pass 24 step from 27

From actions.json in test result

{
    "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"
    }
  }

Robo Script

{
    "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": ""
      }
    ]
  },

From 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.)))))))))))))'.

Solution

  • It looks like Robo correctly found the element to perform the click action on, but the click failed inside Espresso itself. More context is needed to understand why Espresso failed to click on this radio button, e.g., was the radio button fully visible or not, etc. Is there anything else in the log that is pertinent to this exception that could shed more light on the root cause of the problem?

    Additionally, you might use Espresso Test Recorder in Android Studio (Run | Record Espresso Test) to record an Espresso test for exactly same actions that you recorded your Roboscript for. Then, by running this Espresso test, you can check if it fails for the same action and if it does, the error message will contain more context as of why.