Transition animation scale does not disable animation inside application


I encountered a problem while doing some Espresso UI testing: I want to disable the animations inside my application so that i don’t need to set timeouts/need to wait for the animation to finish.

Disabling the Window animation scale, Transition animation scale, Animator duration scale inside the developers options on my android device does not disable the animations while navigating between fragments with the navigation component of android.

The animation is being set like following:

    app:popExitAnim"@anim/slide_out_right" />

How can I disable this animation while running my espresso UI tests?


I followed this guide of google about navigation between fragments with the navigation component.

Then I looked at the guide of google about testing my application with Espresso and on both the first guide and the second guide that i found is that the first point is to disable the animations via developers options, therefore I thought that this was the correct way of disabling the animations


After some more research, I’ve found that Espresso is automatically waiting for all animations on the UI Thread to be finished before executing the assertions.

Normally you don’t have anything to do if you use normal animations..

If you have to wait for a service call to return value inside your Espresso test you can write some code that will (kotlin) extend ViewInteraction class. inside your extension class you can execute the check method and catch any errors. If there is an error, you can give a small timeout (20ms) and try execute it again with a while loop. When after 2-3 seconds you still have an exception, you can then just throw that exception

Answered By – JavascriptDeveloper

Leave a Comment