• 测试工作之--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

  • 相关阅读:
    C#(99):串口编程 System.IO.Ports.SerialPort类
    FastReport.Net的使用
    MongoDB(07):查询文档
    MongoDB(06):文档操作
    HIVE metastore Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)
    RSync实现文件备份同步
    env: /etc/init.d/redis: Permission denied
    Multiple MySQL running but PID file could not be found
    centos 6.5卸载Mysql
    web应用性能测试-Tomcat 7 连接数和线程数配置
  • 原文地址:https://www.cnblogs.com/shenyexiaoqingxin/p/10728376.html
Copyright © 2020-2023  润新知