zoukankan      html  css  js  c++  java
  • 稳定性2: uiautomator控制monkey

    uiautomator控制monkey能做啥?

    (1)可以指定activity遍历, 启动某些组件,例如浏览器 打开某个网站
    (2)判断某些死循环(困死在一个页面)后跳出
    (3)指定增加某些操作,例如滑动,双击,指尖动作,输入
    (4)监控log,遇到crash,anr 马上发生邮件和附件信息
    (5)上传结果到平台,一键提交bug
    (6)检查平台apk打包,定时更新apk
    (7)稳定性好,uiautomator运行在底层,即使所有app内存耗尽被kill,uiautomator还在运行,可以重启monkey运行

    1.可以指定activity遍历 

    -n <COMPONENT>

    直接启动一个组件,例如:adb shell am start -n com.example.app/.ExampleActivity

    2.可以指定启动某些组件,例如浏览器  打开某个网站

    -a <ACTION>

    启动时,要执行的动作,如:android.intent.action.VIEW,我在这里刚开始没有理解他怎么用,网上大部分例子都是:

    adb shell am -a android.intent.action.VIEW -d http://www.baidu.com 启动浏览器打开一个网站

     一个程序的AndroidManifest.xml中的某一个 Activity的IntentFilter段中 定义了包含了相同的Action那么这个Intent就与这个目标Action匹配

    3.判断某些死循环(困死在一个页面)

    用uiautomator api isElementExisted判断某元素是否一直存在

    4.增加某些操作,例如滑动,双击,指尖动作,输入

    5.监控log,在发生问题的时候马上发生邮件

    开启一条线程监控 ANR,CRASH,FATAL EXCEPTION 实时上报数据,截图,记录操作日志 

    { "beginning of crash", "FATAL EXCEPTION", "ANR in " + Constants.pckName + "",
                "Fatal signal"}
    
    //实时开启一条线程监控以上关键字
    public void logRecord() throws IOException { Process p = null; BufferedReader reader = null; String lineTxt = null; String testLog = "logcat -v time"; int num = 0; String date = ""; List<String> writelog = new LinkedList<String>(); try { p = Runtime.getRuntime().exec(testLog); reader = new BufferedReader(new InputStreamReader(p.getInputStream())); while (((lineTxt = reader.readLine()) != null) && isRecord) {

    6.上传结果到平台

     http://www.cnblogs.com/season-xie/p/6506344.html

    7.定时更新apk

    定时监控apk最新路径下的生成情况,每一小时获取最新的apk安装,保持运行apk的最新

    new TimerTask() {
                @Override
                public void run() {
                    // task to run goes here
                    try {
                        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domainip, username, password);
                        SmbFile fp = new SmbFile(remoteurl + basepath, auth);
                        SmbFile[] SF = fp.listFiles();
                        String path = "";
                        long max = 0;
                        SmbFile file = null;
                        for (int i = SF.length - 1; i >= 0; i--) {
                            if (SF[i].getName().contains("prd")) {
                                if (SF[i].getLastModified() > max) {  //获取最新的apk
                                    max = SF[i].getLastModified();
                                    file = SF[i];
                                }
                            }
                        }

    邮件发送:

  • 相关阅读:
    Maven项目多环境之间的配置文件的切换
    使用vue脚手架快速创建vue项目(入门)
    SpringAOP之使用切入点创建通知
    epoll的陷阱
    epoll-1
    openSUSE Leap 15格式化挂载新分区
    openSUSE Leap 15取消自动登录
    openSUSE Leap 15通过windows rdp访问
    openSUSE Leap 15安装打开ssh
    数组、函数与指针
  • 原文地址:https://www.cnblogs.com/season-xie/p/6506339.html
Copyright © 2011-2022 走看看