Android Automation - Espresso - 1

  •   Have you ever got annoyed with this error message while running android test

androidx.test.espresso.PerformException: Error performing 'performing ViewAction: single click on item matching: holder with view: has descendant: with text: is “Hello “’World on view 'Animations or transitions are enabled on the target device.
For more info check: https://developer.android.com/training/testing/espresso/setup#set-up-environment

  • Have you ever got annoyed with device screen turned off 
  • Have you ever forgot to start the emulator before test start


Here's the script to skip those ☺ 


                    setEmulator.sh

emulatorName=$1
echo $emulatorName
$ANDROID_HOME/emulator/emulator -avd $emulatorName & EMULATOR_PID=$!
WAIT_CMD="$ANDROID_HOME/platform-tools/adb wait-for-device shell getprop init.svc.bootanim"
until $WAIT_CMD | grep -m 1 stopped; do
  echo "Waiting..."
  sleep 1
done
echo "done"
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
echo "done1"
# adb uninstall (packagename of app)
adb shell settings put system screen_off_timeout 1800000
adb shell svc power stayon true
adb shell settings put system pointer_location 1
echo "emulator install completed"


 which takes emualtor name as a param

run with terminal/command line

        sh setEmualtor.sh Pixel_API_26

will make the emulator ready.

PS: command to list all installed emulators
avdmanager list avd


Comments

Popular Posts