I am writing uiautomator test case for running Android app program in emulator. Here comes the problem, assume I run the Ui test case in a different emulator machine. How co
Allen Hair answer works just fine if you know what to expect after the click. If you don't (like in my case) you can:
UiAutomation uiAuto = InstrumentationRegistry.getIntrumentation().getUiAutomation(); //gets the UiAutomation for this execution
AccessibilityNodeInfo rootNode = uiAuto.getRootInActiveWindow(); //gets the root node of the currently visible screen
//makes sure there is a rootNode and that is has children, i.e., there is a drawn screen
while(rootNode == null || rootNode.getChildCount() == 0){
rootNode = uiAuto.getRootInActiveWindow();
}
//getting here you are sure that the new screen is drawn.
I do this on top of
device.waitForWindowUpdate(packageName, timeOut)
because in several occasions the wait would return and the root node of the screen could not yet be accessed, resulting in future UiObjectNotFoundException.