Search code examples
androidfirebaseandroid-testingfirebase-test-lab

Inserting delays into robo test script after creating it in the robo script recorder


The automatically-created rob script doesn't insert delays in places that I know my app needs when executing scripted setup operations. How can I use either of these two options that I see might be possible, or is there an approved method? I couldn't find any script command guide, so I'm flying blind.

  1. Grab a copy of an existing "DELAYED_MESSAGE_POSTED" and move it to where I want an added delay.

  2. Edit the "delayTime" of an event that I'd like an additional delay before/after.

I've tried #1 and #2, but it seems that the script won't run after my edits, so either these are not the way to go about this or I messed something up. Any guidance would be greatly appreciated.

Here's a snippet from the script that has both methods. My comments in this script (just for this posting, not in the script I ran) are preceeded by "<<<<-". Note that I'm not including the entire script, just one area I was trying out:

[
...
{
    "eventType": "DELAYED_MESSAGE_POSTED",
    "timestamp": 1570820588045,
    "actionCode": -1,
    "delayTime": 7000,
    "canScrollTo": false,
    "elementDescriptors": []
  },
  {
    "eventType": "VIEW_CLICKED",
    "timestamp": 1570820599551,
    "replacementText": "",
    "actionCode": -1,
    "delayTime": 0,
    "canScrollTo": false,
    "elementDescriptors": [
      {
        "className": "androidx.appcompat.widget.AppCompatImageButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 2,
        "resourceId": "com.jingleware.sosalert:id/ForwardArrow6",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/thanks",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/pager",
        "contentDescription": "",
        "text": ""
      }
    ]
  },
  {  <<<<- added delay  using the first method>
    "eventType": "DELAYED_MESSAGE_POSTED",
    "timestamp": 1570820605000,               <<<<- Here's where I stuck in a value, not knowing what the effect would be 
    "actionCode": -1,
    "delayTime": 1000,
    "canScrollTo": false,
    "elementDescriptors": []
  },
  {
    "eventType": "VIEW_CLICKED",
    "timestamp": 1570820606462,
    "replacementText": "",
    "actionCode": -1,
    "delayTime": 0,            <<<<- I tried to set this to 1000, without the discrete delay that's shown above 
    "canScrollTo": true,
    "elementDescriptors": [
      {
        "className": "androidx.appcompat.widget.AppCompatButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 1,
        "resourceId": "com.jingleware.sosalert:id/NameField",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/userinfoinfo",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.ScrollView",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.jingleware.sosalert:id/userinfoscroller",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 1,
        "resourceId": "com.jingleware.sosalert:id/userinfo",
        "contentDescription": "",
        "text": ""
      }
    ]
  },
...
]

Solution

  • The option #1 is the way to go. The value you assign to 'timestamp' can be just copied from another event. While injecting a copy of a 'DELAYED_MESSAGE_POSTED', please make sure that the resulting script is a well-formed JSON (i.e., has needed commas, does not have unneeded commas, brackets match, etc.). Looking at your sample script, I think it is a valid change and the delay should have worked (assuming 1 second delay was sufficient for your app to stabilize).

    You mentioned that after option #1 change, your script would not run. Does it mean the whole script is not performed or it runs till some action and then fails? How does script execution differ between the original and the modified versions (e.g., at which action it fails)? Thanks!