Select Your Favourite
Category And Start Learning.

Preparing android emulator for UI test automation

Current post explains how to set up android emulator for UI test automation. Properly configured emulator is the basis for reliable tests. Hundreds or thousands of professionally written tests can be great but if they become flaky because of the environment they are running on, their value reduced a lot.

You will receive a couple of advices to follow in your test automation projects. In general we will go through below topics:

  • Managing emulator system animations.
  • Controlling soft keyboard appearance.
  • Changing emulator system locale.

Tweaking first and second points will reduce to minimum flakiness in our automated tests which can be caused by emulator.

Managing emulator system animations

There are three types of system animation we may control:

  • window animation scale
  • transition animation scale
  • animator duration scale

Emulator system animations can be controlled manually from inside the Settings -> Developer options or by executing shell commands as following:

adb shell settings put global window_animation_scale 0.0
adb shell settings put global transition_animation_scale 0.0
adb shell settings put global animator_duration_scale 0.0

Controlling soft keyboard appearance

Running UI tests with soft keyboard is the tricky thing. Based on my experience UI tests are failing from time to time due to clicking on the keyboard instead of UI element. That is why you may want to disable it completely.

Again you can do it manually by switching Show virtual keyboard toggle inside Languages & input -> Physical keyboard settings section or by sending below commands to emulator shell:

adb shell settings put secure show_ime_with_hard_keyboard 0

Changing emulator system locale

Nowadays most of the applications support more than one language. This fact forces us to test our apps with multiple languages.

During manual testing this is achievable by just changing system language from Settings but the same hardly doable from automated tests. Fortunately android emulator has preinstalled Custom locale application which can be used to change system language by simply sending specific intent with extra language parameter to it as below:

adb shell am broadcast -a --es EN

One reply on “Preparing android emulator for UI test automation”

Comments are closed.