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);
      });
    };
    
  • 相关阅读:
    用记事本编写一个Servlet项目
    Servlet开发(一)
    41、java与mysql乱码的问题
    40、JDBC相关概念介绍
    mysql-5.7.12-winx64安装版配置、使用
    39、集合线程安全问题
    38、各Set实现类的性能分析
    电脑取随机数是什么原理,是真正的随机数吗?转自知乎.
    创建Car类,实例化并调用Car类计算运输的原料量是否足够
    用Random类输出验证码
  • 原文地址:https://www.cnblogs.com/wisdomzhang/p/11570566.html
Copyright © 2011-2022 走看看