Mor*_*lau 6 shell automation android adb appium
我正在 Appium 中构建自动化测试场景(针对 Android 应用程序),并试图找出一种在特定时刻开始录制屏幕、运行一些操作然后停止录制的方法。
我找不到任何在 Appium 中实现的屏幕记录解决方案,但找到了一个简洁的 adb shell 命令,screenrecord它完全符合它的规定。现在我的问题是,停止录制的唯一明显方法是在参数中设置我需要的确切时间限制,或者在交互式 shell 中按 Ctrl-C:
2|shell@mako:/ $ screenrecord --help
Usage: screenrecord [options] <filename>
Android screenrecord v1.2. Records the device's display to a .mp4 file.
Options:
--size WIDTHxHEIGHT
Set the video size, e.g. "1280x720". Default is the device's main
display resolution (if supported), 1280x720 if not. For best results,
use a size supported by the AVC encoder.
--bit-rate RATE
Set the video bit rate, in bits per second. Value may be specified as
bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 4Mbps.
--bugreport
Add additional information, such as a timestamp overlay, that is helpful
in videos captured to illustrate bugs.
--time-limit TIME
Set the maximum recording time, in seconds. Default / maximum is 180.
--verbose
Display interesting information on stdout.
--help
Show this message.
Recording continues until Ctrl-C is hit or the time limit is reached.
Run Code Online (Sandbox Code Playgroud)
我可以使用--time-limit,但是我需要估计任何给定的记录在测试中应该花费多长时间,内存使用情况将远非最佳,等等。
使用 Ctrl-C 有其自身的局限性,因为它需要一个交互式 shell 会话,而且我的自动化应该只包括简单的 shell 命令:
adb -s DEVICE_UDID shell screenrecord /sdcard/Recordings/video.mp4
Run Code Online (Sandbox Code Playgroud)
有谁知道一种主动停止录音的方法?
或者,有谁知道如何使用 Appium 记录屏幕?
如果您保存运行屏幕记录的进程,则可以使用信号 SIGINT 进行终止,该信号将按您的意愿工作。
例如:
process = adb shell
process.stdin = screenrecord test.mp4 &
Run Code Online (Sandbox Code Playgroud)
然后当你想杀死它时
process.stdin = pkill -2 screenrecord
Run Code Online (Sandbox Code Playgroud)
应该有效,尝试一下
| 归档时间: |
|
| 查看次数: |
4305 次 |
| 最近记录: |