Providing delay between events in UiAutomator Android

How can I provide delay between event clicks in UiAutomator Android.

First event is entering a url in EditText :

new UiObject(new UiSelector().text("Search here")).setText("");

Here I am loading a webpage inside a webview. So when url loading finishes , then I need to check for second event.

Second event is checking content description of a object :

UiObject curClass = new UiObject(new UiSelector().className("android.widget.RelativeLayout"));  
UiObject yCur = curClass.getChild(new UiSelector().description("ye"));

public void getCurCol() throws UiObjectNotFoundException {
try {
    if (yCur.getContentDescription() != null)
} catch (Exception e) {
    System.err.println("nCaught Exception: " + e.getMessage());

But this doesn’t seem to be working.

I just want the app to wait for some time before checking for the second event.

I know these three methods are provided for delay in UI Automator –

public void waitForIdle(long timeout)

public void waitForIdle()

public boolean waitForWindowUpdate(String packageName, long timeout)

But I don’t know how to use these methods.

Please suggest me a example how to use these.

Any help would be appreciated.



Try just


Let me know whether it works. Or you can try WaitForIdle( ) method.

Leave a Reply

Your email address will not be published. Required fields are marked *