For those regular actions in the app that you have to manually execute every day it’s very easy to write 1 bash script and execute it directly on the device. You can also combine different bash scripts depending on the path of your manual test. To use this technique you don’t need to know programming or configure test automation framework, download the application project or any other tools, and you can perform execution on actual app under your manual testing, not a tweaked app that supports test automation framework. Please note that I am a MAC user and commands might be different for Windows machine.
To avoid app uninstallation and installation steps (although that could be a separate intentional test), we can use the command to clear data from the app. This way all the subsequent executions of the bash script will clear the data of the app, meaning if for example you have registered the user or you have logged into the app, user data will be gone after running:
adb shell pm clear <package name>
Open Text Editor. Your every bash script file should start with:
#!/bin/bash
Let’s look at the possible bash script for Facebook app Login flow:
#!/bin/bash
echo Clear the app
adb shell pm clear com.facebook.katana
echo Launch the app
adb shell am start -n com.facebook.katana/com.facebook.katana.dbl.activity.FacebookLoginActivity
echo Tap into email field
adb shell input touchscreen tap <X> <Y>
echo Enter E-mail address
adb shell input text <email address value>
echo Tap into Password field
adb shell input touchscreen tap <X> <Y>
echo Enter passport
adb shell input text <password value>
echo Tap on LOGIN button
adb shell input touchscreen tap <X> <Y>
For how to find <X> <Y> coordinates please see my other article
Save this file giving the short meaningful name, for example lgG4_login. If you have multiple devices you plan to use bash script on, i recommend phone model as part of the file name. To make this plain text executable, open the directory if the file in the terminal and run:
chmod 700 lgG4_login
To execute your login bash script, attach the phone to computer, and in the terminal within the directory of the bash script run:
./lgG4_login