androidtestingandroid-espressoandroid-testingandroid-autofill-manager

How to disable the new Autofill feature from Android Oreo for espresso tests


Running tests on android devices with sdk 26 causes them to fail because of the new Autofill feature that hides the fields when espresso are trying to click them.

Im running my tests on firebase test lab so I cannot disable them manually on my tests devices.

Some images:

1. Password is visible before clicking username field.

enter image description here

2. After clicking username field password field is hidden by this Autofill dialog:

enter image description here

3. After login it shows another Fill dialog:

enter image description here

Espresso cant click now password field since the autofill dialog is hiding my field and fail.

Using AutofillManager#disableAutofillServices() only disabled the #2. dialog but #3. is still there.

How to disable Autofill on test devices?


Solution

  • adb shell pm disable com.google.android.gms/com.google.android.gms.autofill.service.AutofillService

    This should disable the autofill service. It is same as turning off autofill service in the system settings manually. It at least worked on the emulator. But this needs root access.

    Another way to disable the autofill service is to change the autofill_service settings.

    adb shell settings put secure autofill_service null