Is it possible to wait until animation is finished before interacting with element?


animation in app I work with is quite slow, so when the tests running, they fail often with exceptions. Adding sleep(500) before steps does help, but I believe it is not the best solution. Is it possible to wait until animation is finished?


Identify what will appear once animation ends and look for it. For example if after an animation text “Hello, I’m back” appears then run:

wait { text("Hello, I'm back") }

If the animation are so slow that it may hit the timeout defined, then use some while

while texts("Hello, I'm back).size == 0 do
    sleep 0.5

In this last one its better to also have one counter incrementing and if it reaches a number you define just raise an exception to fail the test or it may run forever. Examples in ruby, just adapt to your favorite language.

Thanks! That’s what I wanted to do. But I think it would be simpler and more logical to wait for finishing the animation instead of presence/disappearance of elements. For example, Calabash has wait_for_none_animating.
So I wonder if you can do something similar with the Appium.


When animating, perhaps we can check the coordinates of an element that is moving, wait for a little, then check the coordinates again. If the coordinates before and after has a delta, then we know the element is still animating, else, animation is done.

I use @alangithubtrader’s method for waiting for some animations to complete. I actually use a WebDriverWait for these sorts of animations.

If this is an Android device, you can disable a large set of animations through the developer options under the device’s settings menu. However, even with these disabled, there might be some animations that still persist, but it’s a good step forward towards stability.

1 Like

Thanks for your idea.

It helped me to automate iOS AUT page spinner