Appium Run Error command failed shell:............ps: ' Uiautomator ' solution on Android 7.0 Real machine

Source: Internet
Author: User
Tags appium

Appium version: 1_4_16

Find the solution in Csdn, according to this solution to solve the problem of melancholy, again record.

1. Locate the Adb.js file in Appium installation directory: Appium\node_modules\appium\node_modules\appium-adb\lib

2, open adb.js, you can use the Notepad++ editor and other open files (note: In the code changes when the first comment out the previous code, and add their own easy to identify the mark, in case there is a wiggle room after the error, or the code backup is also feasible), find the following code:

ADB.prototype.shell = function (cmd, CB) {  if (Cmd.indexof ('"') = = = = 1 ) {    '"'"';  }   var '  ' + cmd;    This . EXEC (ExecCmd, CB);};

Add the following code below this code:

ADB.prototype.shell_grep =function (cmd, grep, CB) {if(Cmd.indexof ('"') === -1) {cmd='"'+ cmd +'"'; }  varExecCmd ='Shell'+ cmd +'| grep'+grep;  This. EXEC (ExecCmd, CB);};

Find the following code again:

ADB.prototype.getPIDsByName =function (name, CB) {Logger.debug ("Getting All processes with '"+ name +"'");  This. Shell ("PS '"+ name +"'", function (err, stdout) {if(ERR)returnCB (ERR); StdOut=Stdout.trim (); varProcs = []; varoutlines = Stdout.split ("\ n");    Outlines.shift (); _.each (outlines, function (outline) {if(Outline.indexof (name)!==-1) {Procs.push (outline);    }    }); if(Procs.length <1) {Logger.debug ("No matching processes found"); returncbNULL, []); }    varPIDs = []; _.each (procs, function (proc) {varMatch =/[^\t]+[\t]+ ([0-9]+)/. EXEC (proc); if(Match) {Pids.push (parseint (match[1],Ten));    }    }); if(Pids.length!==procs.length) {varmsg ="Could not extract PIDs from PS output. PIDS:"+json.stringify (PIDs)+", procs:"+json.stringify (procs); returncbNewError (msg)); } CB (NULL, PIDs); });};

Comment out the above code and replace it with the following code:

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"); returncbNULL, []); }    varPIDs = []; _.each (procs, function (proc) {varMatch =/[^\t]+[\t]+ ([0-9]+)/. EXEC (proc); if(Match) {Pids.push (parseint (match[1],Ten));    }    }); if(Pids.length!==procs.length) {varmsg ="Could not extract PIDs from PS output. PIDS:"+json.stringify (PIDs)+", procs:"+json.stringify (procs); returncbNewError (msg)); } CB (NULL, PIDs); });};

3, restart the Appium, connected to the successful operation of the phone to see the resolution is OK

Appium Run Error command failed shell:............ps: ' Uiautomator ' solution on Android 7.0 Real machine

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.