Search code examples
androidamazon-web-servicesandroid-espressoaws-device-farm

Can we disable a dialog box in aws device farm for Android espresso tests


We are using aws device farm for running all our android espresso tests. If you see the below image, this dialog box is making our few tests to fail. enter image description here

Is there anyway we can disable this dialog box while running the tests? Or is there a way we can run adb command in the console before running the tests. I will highly appreciate any input you can provide. Thank you


Solution

  • I don't know a way to use adb at aws prior test run to grant permissions but ...

    An alternative could be to handle system dialogs with UiAutomator. This tool can be used in combination with Espresso.

    sample:

    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    UiObject button = device.findObject(new UiSelector().text("Allow"));
    button.click();
    

    necessary dependency:

    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
    

    I have started to write an library which should make testing more simple with espresso and uiautomator. This includes tooling for permission handling. https://github.com/nenick/espresso-macchiato See EspPermissionDialog and EspPermissionsTool