从日志来看,提示原因是,匿名函数没有 stop 方法,追一下源码:
androidHybrid.cleanupChromedriver = function (chromedriver, cb) {
if (chromedriver) {
logger.debug("Cleaning up Chromedriver");
chromedriver.stop(function (err) {
if (err) logger.warn("Error stopping chromedriver: " + err.message);
this.restoreProxyState();
cb();
}.bind(this));
} else {
cb();
}
};
往上追一下:
Chromedriver.prototype.stop = function (cb) {
logger.debug('Killing chromedriver');
this.exitCb = cb;
this.proc.kill();
};
再往上追
this.onChromedriverStart = cb;
logger.debug("Spawning chromedriver with: " + this.chromedriver);
var alreadyReturned = false;
var args = ["--url-base=wd/hub", "--port=" + this.proxyPort, "--adb-port=" + ADB.getAdbServerPort()];
this.proc = spawn(this.chromedriver, args);
this.proc.stdout.setEncoding('utf8');
this.proc.stderr.setEncoding('utf8');
this.proc.on('error', function (err) {
logger.error('Chromedriver process failed with error: ' + err.message);
alreadyReturned = true;
this.shuttingDown = true;
logger.error('Killing chromedriver');
this.proc.kill();
this.onDie();
}.bind(this));
能贴一下你的代码吗?