Sure, it’s actually really simple. I’m doing the following on a mac, but you can easily do it on windows as well
- Download adb and appt and put them in your root user on your mac i.e. ~/
- Place the script.command and the apk you want to test on in the same folder
- Chmod the script to 777
- Make sure your phone is plugged into your computer (you can do it over tcpip as well but it’s much slower)
- Double tap the script and watch it do its thing
~/adb shell input tap X Y #adb tap event
~/adb shell input touchscreen swipe X1 Y1 X2 Y2 DURATION #adb swipe event
1 huge gotcha is the fact that adb uses x and y of the device based on various factors. So if you setup a test and it works perfectly on 1 device more then likely all the touch points will be off on a different device. Ohh and to get the X / Y locations turn on developer options on the device and enable show touches. Now when you tap you will be able to quickly get the X / Y of the tap.
#!/bin/bash DIR="$( cd "$( dirname "${BASH\_SOURCE[0]}" )" && pwd )" cd "$DIR"; for i in "$DIR"/\*.apk; do ~/adb install -r "$i"; pkg=$(~/aapt dump badging "$i"|awk -F" " '/package/ {print $2}'|awk -F"'" '/name=/ {print $2}') act=$(~/aapt dump badging "$i"|awk -F" " '/launchable-activity/ {print $2}'|awk -F"'" '/name=/ {print $2}') ~/adb shell am start -n $pkg/$act name=`~/adb shell dumpsys activity activities | grep mFocusedActivity | cut -d . -f 5 | cut -d ' ' -f 1` #Make sure we're still in the game "ansca" is corona sdk apps echo $name if ["$name" == 'ansca'] || ["$name" == 'corona']; then #create folder name based on apk name fname="${i}" replaceText="" fname=${fname/.apk/$replaceText} #change path NEWDIR="$(dirname "${i}")" cd "$NEWDIR" mkdir "${fname}" cd "${fname}" #sleep = pause sleep 10 ######################### NO NEED TO EDIT ANYTHING ABOVE HERE ######################### #----------------------------------- #log-in as guest #----------------------------------- ~/adb shell input tap 906 703 #Play as guest ~/adb shell input tap 398 542 #Hit the back button ~/adb shell input tap 906 703 #Play as guest button ~/adb shell input tap 800 534 #Play as guest red button ~/adb shell input tap 842 440 #Hit the allow permission popup sleep 10 #----------------------------------- #END log-in as guest #----------------------------------- #----------------------------------- #tap on the users avatar and change their name/icon #----------------------------------- ~/adb shell input tap 63 42 #Tap on users avatar sleep 2 ~/adb shell input tap 680 200 #Tap on the username field sleep 3 #Press and hold down on backspace ~/adb shell input touchscreen swipe 1200 515 1200 515 5 #Type the name dave ~/adb shell input tap 362 600 #the letter d ~/adb shell input tap 158 600 #the letter a ~/adb shell input tap 531 676 #the letter v ~/adb shell input tap 324 512 #the letter e ~/adb shell input tap 1160 600 #the done button sleep 2 ~/adb shell input tap 985 614 #Tap on an avatar ~/adb shell input tap 1075 480 #Tap on next page button ~/adb shell input tap 1075 480 #Tap on next page button ~/adb shell input tap 985 614 #Tap on an avatar #take a screenshot of the main scene ~/adb shell screencap -p /mnt/sdcard/avatar.png ~/adb pull /mnt/sdcard/avatar.png ~/adb shell input tap 1196 45 #Close avatar page sleep 10 #----------------------------------- #END tap on the users avatar and change their name/icon #----------------------------------- #~/adb shell input touchscreen swipe 585 212 135, 212 #~/adb shell input tap 350 1475 fi #uninstall app ~/adb uninstall $pkg done