Wait until scrollbar fades when using UI Automator

386 views Asked by At

I'm using UI Automator for automating screenshots of my app. But I want to ensure the scrollbar has faded out before taking the screenshot. Currently I'm simply using the naïve approach of calling SystemClock.sleep() but I'm wondering if there's a way to detect the presence of a scrollbar either as a separate object or as a property of a ListView and wait for a state change?

As an alternative solution, is it possible to disable scrollbars during tests?

1

There are 1 answers

1
Inês On

You can use UiDevice.waitForWindowUpdate(PackageName, timeout).

I'm not sure if it works for fading scrollbars but I think it should. It basically waits for the window to be updated or until a defined timeout.

EDIT: Another way: if you have the corresponding UiObject you can use waitUntilGone