zoukankan      html  css  js  c++  java
  • Error: Command failed: C:windowssystem32cmd.exe /s /c "E:programfilesandroidSDKplatform-toolsadb.exe -s emulator-5554 shell "ps 'uiautomator'""

    问题

    appium等自动化环境都安装配置号后,遇到如下问题:

    Error: Command failed: C:windowssystem32cmd.exe /s /c "E:programfilesandroidSDKplatform-toolsadb.exe -s emulator-5554 shell "ps 'uiautomator'""

    解决方案

    网上找到了解决方法,点击这里 也可查看本篇

    • 他讲的内容似乎有点重复,第一步改好的,在最后一步注释掉了。

    具体步骤如下:

    1.找到adb.js文件,路径为appium的安装路径下:node_modulesappium ode_modulesappium-adblib
    2.找到如下代码:

    ADB.prototype.shell = function (cmd, cb) {
      if (cmd.indexOf('"') === -1) {
        cmd = '"' + cmd + '"';
      }
      var execCmd = 'shell ' + cmd;
      this.exec(execCmd, cb);
    };
    

    修改:var execCmd = 'shell ' + cmd;var execCmd = 'shell ' + cmd + '| grep ' + grep;
    3.找到如下代码:

    ADB.prototype.getPIDsByName = function (name, cb) {
      logger.debug("Getting all processes with '" + name + "'");
      this.shell("ps '" + name + "'", function (err, stdout) {
        if (err) return cb(err);
        stdout = stdout.trim();
        var procs = [];
        var outlines = stdout.split("
    ");
    	outlines.shift();
        _.each(outlines, function (outline) {
          if (outline.indexOf(name) !== -1) {
            procs.push(outline);
          }
        });
        if (procs.length < 1) {
          logger.debug("No matching processes found");
          return cb(null, []);
        }
        var pids = [];
        _.each(procs, function (proc) {
          var match = /[^	 ]+[	 ]+([0-9]+)/.exec(proc);
          if (match) {
            pids.push(parseInt(match[1], 10));
          }
        });
        if (pids.length !== procs.length) {
          var msg = "Could not extract PIDs from ps output. PIDS: " +
                    JSON.stringify(pids) + ", Procs: " + JSON.stringify(procs);
          return cb(new Error(msg));
        }
        cb(null, pids);
      });
    };
    

    修改为:

    ADB.prototype.getPIDsByName = function (name, cb) {
      logger.debug("Getting all processes with '" + name + "'");
      this.shell_grep("ps", name, function (err, stdout) {
        if (err) {
          logger.debug("No matching processes found");
          return cb(null, []);
        }
        var pids = [];
        _.each(procs, function (proc) {
        var match = /[^	 ]+[	 ]+([0-9]+)/.exec(proc);
        if (match) {
        pids.push(parseInt(match[1], 10));
        }
        });
        if (pids.length !== procs.length) {
          var msg = "Could not extract PIDs from ps output. PIDS: " +
          JSON.stringify(pids) + ", Procs: " + JSON.stringify(procs);
          return cb(new Error(msg));
        }
        cb(null, pids);
      });
    };
    
  • 相关阅读:
    HBase导入数据同时与Phoenix实现同步映射
    Hive导入数据到HBase,再与Phoenix映射同步
    CDH5.16.1离线集成Phoenix
    设计原则学习笔记
    Maven安装配置
    SpringBoot之Mybatis操作中使用Redis做缓存
    Linux服务器防火墙白名单设置
    Linux查看端口占用情况,并强制释放占用的端口
    shell脚本切割tomcat日志文件
    mysql读写分离
  • 原文地址:https://www.cnblogs.com/wisdomzhang/p/11570566.html
Copyright © 2011-2022 走看看