test-butler icon indicating copy to clipboard operation
test-butler copied to clipboard

TestButler should close system dialogs that are shown at the moment it is starting

Open SKART1 opened this issue 7 years ago • 5 comments

We in our team have faced some problem: before our test have started(and testButler was initialised) google play services have have crashed - so System Dialog appeared and test did not pass

Is there any instrument which allows testButler to close already opened dialogs? Should it be used when testButler is starting?

P.S. We have made a solution based on uiautomator - but I am not sure it is the best one:

 UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
        UiObject crashMessageView = uiDevice.findObject(new UiSelector().resourceId(("android:id/message")));
        if (crashMessageView != null) {
            try {
                TestLog.w("Crash alert is found = " + crashMessageView.getText());
                uiDevice.findObject(new UiSelector().resourceId(("android:id/button1"))).click();
            } catch (UiObjectNotFoundException e) {
                TestLog.w("Could not click on crash dialog\n " + e);
            }
        }

SKART1 avatar Mar 17 '17 15:03 SKART1

you might be interested in UiWatchers.java

bootstraponline avatar Mar 17 '17 16:03 bootstraponline

@bootstraponline We are facing ErrorDialog which was fired before our app was started

SKART1 avatar Mar 17 '17 16:03 SKART1

Have you updated Google Play services? And which devices, API was it crashing on?

Kisty avatar Mar 17 '17 17:03 Kisty

We typically solve this by making sure we send a back button key event via adb before starting tests.

drewhannay avatar Mar 17 '17 18:03 drewhannay

There is yet another fix sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); after TestButler setUp that solves the issue.

vovam avatar Apr 13 '17 15:04 vovam