Skip to content
master
Switch branches/tags
Code

replaykit Build Status Windows Build

中文说明

replaykit is a command line tool intended for mobile continuous integration, which provides the ability to:

  • record touchscreen events from one device and replay to many (aspect ratios must be the same)
  • control multiple devices concurrently (e.g., run a shell command, install an app, etc.)
  • mirror the touchscreen events from one device to many in real time (aspect ratios must be the same)

replaykit can work on Windows 7+, MacOS Mavericks+ and Linux, available for Android API 9-27(9.0 aka. P), emulators, VMs (like Genymotion) and real devices. To integrate replaykit with existing CI infrastructure, consider the Python wrapper.

Please submit issues for bug reports, enhancements and feature requests. Pull requests for documentation improvement are welcomed too.

Installation

The executable file can be found in the darwin/ for MacOS, win32/ for Windows and linux/ for Ubuntu, Fedora and CentOS. You might want to add to PATH to use the tool globally. Linux and MacOS build are both 64-bit and Windows build is 32-bit (compatible with 64-bit as WOW). replaykit requires adb to be present in PATH. You can install the Android SDK and ensure <sdk>/platform-tools is in your PATH.

Control Multiple Devices

Suppose you have several devices attached to the development machine via USB and you want them to perform the same action.

First, make sure replaykit recognizes all of them devices:

./darwin/replaykit devices list

You should see a JSON output. Note the serialno field, which is the same as the adb devices output. A serialno uniquely identifies a connected device.

Next, you can try these:

DEVICE=serialno1,serialno2 # device serialnos, comma separated, no whitespace!
replaykit devices control $DEVICE uninstall com.helloworld # uninstall an app on those devices
replaykit devices control $DEVICE install hellworld.apk # install an app
replaykit devices control $DEVICE kill_all # kill all background apps
replaykit devices control $DEVICE launch_pkg com.helloworld # launch an app
replaykit devices control $DEVICE shell input keyevent KEYCODE_HOME # simulate the home button
replaykit devices control $DEVICE shell pm grant com.helloworld android.permission.SOME_PERMISSION  # grant a permission to an app 
replaykit devices control $DEVICE shell "input keyboard text 'Paste%stext%son%sAndroid%sDevice'"  # input text (pre Android 6)
replaykit devices control $DEVICE shell "input keyboard text 'Paste text on Android Device'"  # input text (Android 6+)
replaykit devices control $DEVICE shell screenrecord /sdcard/demo.mp4  # record screen into a video(Android 4.4+)

Basically everything you did with adb shell can now be replaced with replaykit devices control serialno1,serialno2 shell to perform that on multiple devices simultaneously.

And, just in case you need them:

Record and Replay touchscreen events

Replaykit can record touchscreen events from one device and replay back to many to automate stuff.

replaykit trace record --device serailno mytrace.trace

Now find the device and start touching. The touchsceen events will be captured and saved to mytrace.trace. If you are done, type in exit to stop. You are all set if seeing "Recorder stopped, trace saved to mytrace.trace". Try not to use Ctrl+C.

Check if the trace is good:

replaykit trace info mytrace.trace

Again, it shows a JSON about the recorded trace, showing the screen resolution, time length, how many fingers, etc. To modify the description of this trace, use replaykit trace describe mytrace.trace "the description to be added".

Next replay the trace back to see how it goes:

replaykit trace replay mytrace.trace serialno

You will see something like the video below:

Record and replay

If you want to replay to more than one devices, simply replace serialno with a comma-separated serialno list like serialno1, serialno2.

Mirror Touchscreen Events

With replaykit, you can mirror the touchscreen events from one device to other devices in real time.

replaykit devices mirror <from_device> <to_device>

The <from_device> is a single serialno while <to_device> can be a comma-separated list of device serialnos. Make sure all involving devices have the same aspect ratio. Otherwise the command will fail. For devices with the same aspect ratio, the touchscreen events will automatically scale to adapt to the screen resolution.

Here is a demo:

mirroring

ADB related

Finally, replaykit provides some commands to check the ADB environment.

replaykit adb start-server  # start the ADB server
replaykit adb kill-server  # kill the ADB server
replaykit adb detectadb  # this tells where the adb binary locates. If not found, tune your PATH
replaykit adb check-server  # check if the adb server is running properly now

License

Apache License v2