You can run your UI test specific to your Android app and have the whole process screen recorded using one Bitrise workflow. Here is an example workflow containing the steps we will use in this guide:
- Add the
AVD Manager
Step at the beginning of your workflow to create and run an Android Virtual Device. - Add the
Wait for Android Emulator
Step after theAVD Manager
Step. This Step makes sure that the Android emulator has finished booting before the screen recording would start. - Add a
Script
Step after theWait for Android Emulator
Step. (We’re renaming thisScript
Step asStart screen recording
Step.) -
Insert the following commands to the
Script content
input field:$ANDROID_HOME/platform-tools/adb shell "screenrecord /sdcard/video.mp4 --verbose" &> $BITRISE_DEPLOY_DIR/logs.txt & disown $ANDROID_HOME/platform-tools/adb shell "screencap -p /sdcard/screen.png" &> $BITRISE_DEPLOY_DIR/logs.txt & disown
Start screen recording
Step kills two birds with one stone:- starts screen recording before UI testing
- captures a screenshot of the emulator screen BEFORE the UI test would start
- Add another
Script
Step after theStart screen recording
Step. (We will call itRun UI test
Step.)- Add your script (for example, Maven, npm or Appium tests) in the
Script content
input field to call and run your UI test.
- Add your script (for example, Maven, npm or Appium tests) in the
- Insert the third
Script
Step (Stop Screen recording & get file from emulator
) after theRun UI tests
Step. -
Add the following script to the
Script content
input field.$ANDROID_HOME/platform-tools/adb shell "killall -INT screenrecord" sleep 10 $ANDROID_HOME/platform-tools/adb pull /sdcard/video.mp4 $BITRISE_DEPLOY_DIR/video.mp4 adb pull /sdcard/screen.png $BITRISE_DEPLOY_DIR/ $ANDROID_HOME/platform-tools/adb shell "screencap -p /sdcard/screen2.png" &> $BITRISE_DEPLOY_DIR/logs.txt & disown adb pull /sdcard/screen2.png $BITRISE_DEPLOY_DIR/
Stop Screen recording & get file from emulator
Step does the following:- stops the screen recoding,
- gets the screen recording,
- gets those Emulator screenshots that had been taken before UI tests started
- gets the final screenshot of the Emulator screen
- places these files in the
BITRISE_DEPLOY_DIR
path
- Add the
Deploy to Bitrise.io - Apps, Logs, Artifacts
Step to your workflow to export all files stored in theBITRISE_DEPLOY_DIR
directory toAPPS & ARTIFACTS
. You can check these files at theAPPS & ARTIFACTS
tab of your Build’s page. (Note that if you did not place the files in this directory, they will not be deployed to theAPPS & ARTIFACTS
tab of your Build’s page.)
If your build fails due to No such process
(error message below) or an Encoder failed (err=-38)
error in your build log, most likely the screen resolution of the screen recording and the device does not match.
/opt/android-sdk-linux/platform-tools/adb shell 'killall -INT screenrecord' killall: screenrecord: No such process
Here is what to check:
- Check if you have the right resolution set in the
Resolution
field of theAVD Manager
Step. - If you’re NOT using the
AVD Manager
Step to start the emulator (and useScript
Step instead), then you can fix the screen size in theScript content
field of theStart screen recording
Step by specifying the width and height of the screen:--size <WIDTHxHEIGHT>
.