0
votes

Our app has a 'google' account choosing functionality (not authenticating; just linking)

Here is the google acount chooser intent looks like

Intent intent = AccountPicker.newChooseAccountIntent(null,
                null,
                new String[]{"com.google"},
                true,
                null,
                null,
                null,
                null);
        startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT)

When I test the app in my emulator, I choose a dummy google account. I do the same when capturing Robo test recording also.

And my Robo json looks like this before showing the account choosing prompt

{
    "eventType": "VIEW_CLICKED",
    "timestamp": 1567317991869,
    "replacementText": "Choose a Google Account",
    "actionCode": -1,
    "delayTime": 0,
    "canScrollTo": false,
    "elementDescriptors": [
      {
        "className": "android.support.v7.widget.AppCompatButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 2,
        "resourceId": "com.app.xyz:id/btn_main_propic",
        "contentDescription": "",
        "text": "Choose a Google Account"
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.app.xyz:id/id_main_rlyt",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.support.v7.widget.ContentFrameLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "android:id/content",
        "contentDescription": "",
        "text": ""
      }
    ]
  }

And after choosing the account, my robo script has this.

{
    "eventType": "VIEW_CLICKED",
    "timestamp": 1567318000894,
    "replacementText": "I Agree, Proceed",
    "actionCode": -1,
    "delayTime": 0,
    "canScrollTo": false,
    "elementDescriptors": [
      {
        "className": "android.support.v7.widget.AppCompatButton",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 5,
        "resourceId": "com.app.xyz:id/btn_first_proceed",
        "contentDescription": "",
        "text": "I Agree, Proceed"
      },
      {
        "className": "android.widget.RelativeLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "com.app.xyz:id/id_main_rlyt",
        "contentDescription": "",
        "text": ""
      },
      {
        "className": "android.support.v7.widget.ContentFrameLayout",
        "recyclerViewChildPosition": -1,
        "adapterViewChildPosition": -1,
        "groupViewChildPosition": 0,
        "resourceId": "android:id/content",
        "contentDescription": "",
        "text": ""
      }
    ]
  }

As you can notice above, there is no entry for choosing the account. i.e. clicking on the account name.
Now this is where the problem arises when i test it in the cloud. Instead of using the existing google account, the Robo goes to create new account and fails.

The prompt in the cloud test looks like this.

Google account choosing prompt in cloud test

The test should choose the first option. Instead it selects 'Add Account' option and starts creating an account and fails.

The questions are.

  1. Why robo json is not capturing the account choosing step?
  2. What needs to be done to use the existing google account in cloud device?

Pls note that, its not authentication as explained in this page. It is only linking of an existing account (just any account would do).

1

1 Answers

0
votes
  1. Roboscript recorder is not capturing the account choosing step because the choosing dialog is not part of the recorded app. You can confirm this with Run | Record Espresso Test in Android Studio. Espresso Test Recorder would not capture your action in account choosing dialog as well. Since account choosing action is not part of the recorded Roboscript, when the account choosing dialog shows up during a Robo crawl, Robo will try to perform "I Agree, Proceed" from the Roboscript. Since this action fails because the corresponding UI element is not found on the screen, Robo gives up on performing the Roboscript and starts a normal crawl, picking the second option ("Add account") for some reason (please note that even if Robo picked the first option, Roboscript is no longer being performed at this point, so on subsequent screens Roboscript actions will not be performed anyway).

  2. In a normal Robo crawl, as explained by the user help page you linked, Robo will automatically perform a Google login. In your case, this login (which is not a login, but an account picking) happens within the steps of the Roboscript, so the only way to make sure the Roboscript is fully performed is to inject the missing action into it. You can manually edit the recorded Roboscript, adding the following action in between two Roboscript actions you listed above. Replace placeholders with the actual values of the element on which you would like Robo to click, although class name does not need to be precise. Also, you can tweak this action further using the code below and examples of the recorded Roboscript actions above as a starting point.


  {
    "eventType": "VIEW_CLICKED",
    "elementDescriptors": [
      {
        "className": "some_class_name",
        "text": "text_of_the_option_to_pick"
      }
    ]
  },

Alternatively, you might tweak your app to not show out-of-app dialogs when you record and replay a Roboscript, e.g., by linking the existing account programmatically.