• 测试工作之--adb代码


    1.抓log方法 (bat文件) 
    mkdir D:logcat
    set /p miaoshu=请描述操作:
    adb logcat -v threadtime > D:logcat\%miaoshu%_%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%-%time:~3,2%.txt

    2.抓anr的方法:

    adb pull data/anr/traces.txt > D:

    3. 跑monkey脚本(bat文件)

    set beginTimes=1500
    adb shell monkey -p com.jd.smart.fridge.launcher -p --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v --throttle %beginTimes% 100000 > D:monkey_01.txt 
    ping -n 40 127.0>nul
    adb shell monkey -p com.jd.smart.fridge.launcher -p --ignore-crashes --ignore-timeouts --ignore-security-exceptions --ignore-native-crashes --monitor-native-crashes -v -v -v --throttle %beginTimes% 100000 >> D:monkey_01.txt

    4.录测试apk的视频、截图并导出到本地 (view.bat,screen.bat) 

    ::安卓截图命令
    adb shell screencap -p /sdcard/screen.png #-p以png的格式保存截图
    @ping -n 5 127.1 >nul 2>nul
    ::更改当前目录为批处理本身的目录
    cd/d "%~dp0" 
    ::获取当前时间
    set y=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
    ::创建目录
    md %y%
    ::把图片导出来
    adb pull /sdcard/screen.png %y%
    ::删除手机中所截的图
    adb shell rm -r /sdcard/screen.png

    ::安卓录屏命令
    set /p t=请输入时间(秒):5
    adb shell screenrecord --time-limit %t% /sdcard/view.mp4
    @ping -n 5 127.1 >nul 2>nul
    ::更改当前目录为批处理本身的目录
    cd/d "%~dp0"
    ::获取当前时间
    set y=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
    ::新建目录
    md %y%
    ::把视频导出来
    adb pull /sdcard/view.mp4 %y%
    ::删除手机中所录的视频
    adb shell rm -r /sdcard/view.mp4

    5.adb命令获取CPU、内存PSS

    CPU:

    adb shell top -m 5 > D:/CPU.txt

    PSS:

    set process=com.jd.smart.fridge.launcher

    adb shell dumpsys meminfo %process% | findstr "Pss"

    :m

    adb shell dumpsys meminfo %process% | findstr "TOTAL" >> D:/PSS.txt

    ping -n 5 127.0.0.1>nul

    goto m

  • 相关阅读:
    2017年7月10日 20:34:02 简易博客记录组
    Oracle审计表AUD$处理方法 (Z)
    Oracle中trace的几种(Z)
    查看oracle数据库是否归档和修改归档模式(转)
    oracle exp-000991
    基于公司级平台封装的SqlserverHelper
    pycharm运行测试程序提示no tests were found
    10-13 验证用户
    10-11 喜欢的数字
    10-1 Python 学习笔记
  • 原文地址:https://www.cnblogs.com/shenyexiaoqingxin/p/10728376.html
Copyright © 2020-2023  润新知