This post is about setting up android emulator for UI test automation. Properly configured emulator is the basis for reliable tests. Hundreds or thousands of professionally written test cases is great but if they become flaky because of the environment they are running on, their value reduces a lot.
I will give you a couple of advices I'm following in my test automation projects. In general we will go through below topics:
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:
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:
I will give you a couple of advices I'm following in my 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.
For those who are lazy to read the whole article at the bottom of the post I shared youtube video where I describe the same points with one more additional hint on top :)
For those who are lazy to read the whole article at the bottom of the post I shared youtube video where I describe the same points with one more additional hint on top :)
1. 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" as shown on screen shot below
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.02. 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 03. 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 com.android.intent.action.SET_LOCALE --es com.android.intent.extra.LOCALE ENMore information you can find in the following video:
Comments
Post a Comment