alibaba / macaca

Automation solution for multi-platform. 多端自动化解决方案
https://macacajs.github.io
MIT License
3.16k stars 418 forks source link

macaca server运行失败 #1009

Closed 1161004155 closed 1 year ago

1161004155 commented 2 years ago

我的目的是在iOS真机或者模拟器上跑起来nosmoke,但是在启动macaca server的时候出现了问题,一直启动不起来 我的步骤如下:

  1. 按照官网(https://macacajs.github.io/zh/guide/environment-setup.html#%E5%AE%89%E8%A3%85-node-js)的方法,配置好了环境,macaca doctor全绿,截图如文末Macaca Doctor Logs中所示

  2. 安装有 TEAM_ID 的 macaca-ios后,cd "$(npm root -g)/macaca-ios/node_modules/xctestwd",xcode编译下面的XCTest项目,Run Test 将 XCTestWDUITest 装入模拟器并开始测试,模拟器是IPhone 8,iOS13.7

  3. 此时执行macaca server --verbose,结果如下,这是一直解决不了的问题,这里是需要在什么目录下修改配置文件吗,还是别的什么问题,需要我提供别的信息的话也随时可以

    image
  4. 失败之后,试着跑sample-java和nosmoke都失败了,但是app-inspector可以执行

happybeta commented 2 years ago

我也和你差不多的问题。不同的是,我是Android平台的。

  1. macaca doctor是正常的, 都绿了。

    macaca doctor
    
    macaca-doctor version: 2.0.18
    
    Node.js checklist:
    
    node env: C:\Program Files\nodejs\node.exe
    node version: v12.18.3
    
    Android checklist:
    
    JAVA version is `1.8`
    JAVA_HOME is set to `C:\Program Files\Java\jdk1.8.0_151`
    ANDROID_HOME is set to `D:\android\Sdk`
    Platforms is set to `D:\android\Sdk\platforms\android-30`
    ADB tool is set to `D:\android\Sdk\platform-tools\adb.exe`
    GRADLE_HOME is set to `C:\Users\Desktop\自主测试\nosmoke\gradle-7.5`
    
    Installed driver list:
    
    android: 2.2.1
    location: C:\Users\AppData\Roaming\npm\node_modules\macaca-android

2 , 启动macaca server失败,换了个多个版本,都提示:

C:\Users\user>macaca server --verbose
>> request.js:11:12 [master] pid:12876 get remote update info failed.
>> index.js:15:12 [master] pid:16828 webdriver server start with config:
 {
  port: 3456,
  verbose: true,
  always: true,
  ip: 'masked',
  host: 'masked',
  loaded_time: '2022-07-26 17:29:40'
}
>> middlewares.js:17:10 [master] pid:16828 base middlewares attached
>> index.js:40:14 [master] pid:16828 webdriver server failed to start: Error: get `/wd/hub/status`: `middleware` must be a function, not `undefined`
    at Layer.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\layer.js:38:13)
    at Array.forEach (<anonymous>)
    at new Layer (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\layer.js:35:14)
    at Router.register (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\router.js:503:15)
    at Router.<computed> [as get] (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\router.js:184:10)
    at module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\router.js:53:6)
    at C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\index.js:36:7
    at new Promise (<anonymous>)
    at module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\index.js:14:10)
    at Webdriver.start (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\index.js:24:10)
(node:16828) UnhandledPromiseRejectionWarning: Error: get `/wd/hub/status`: `middleware` must be a function, not `undefined`
    at Layer.<anonymous> (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\layer.js:38:13)
    at Array.forEach (<anonymous>)
    at new Layer (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\layer.js:35:14)
    at Router.register (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\router.js:503:15)
    at Router.<computed> [as get] (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\koa-router\lib\router.js:184:10)
    at module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\router.js:53:6)
    at C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\index.js:36:7
    at new Promise (<anonymous>)
    at module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\server\index.js:14:10)
    at Webdriver.start (C:\Users\user\AppData\Roaming\npm\node_modules\macaca-cli\node_modules\webdriver-server\lib\index.js:24:10)
(node:16828) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:16828) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
candialala commented 2 years ago

你好,来信已收到~~我会尽快查收并回复的! XMU Software 陈晓娟    

CodeByShawn commented 2 years ago

同样问题,有解决方案吗?

CodeByShawn commented 1 year ago

请问有解决吗

AtuboDad commented 1 year ago

同样问题,有解决方案吗?

candialala commented 1 year ago

你好,来信已收到~~我会尽快查收并回复的! XMU Software 陈晓娟    

1161004155 commented 1 year ago

macaca server启动,中间件报错,需要修改/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/server/controllers/cookie.js,替换为下面的内容:

'use strict';

function *getAllCookies(next) {
  this.state.value = yield this.device.getAllCookies();
  yield next;
}

function *getNamedCookie(next) {
  const body = this.request.body;
  const name = body.name;

  this.state.value = yield this.device.getNamedCookie(name);
  yield next;
}

function *addCookie(next) {
  const body = this.request.body;
  const cookie = body.cookie;
  this.state.value = yield this.device.addCookie(cookie);
  yield next;
}

function *deleteCookie(next) {
  const name = this.request.body.name || this.params.name;

  this.state.value = yield this.device.deleteCookie(name);
  yield next;
}

function *deleteAllCookies(next) {
  this.state.value = yield this.device.deleteAllCookies();
  yield next;
}

module.exports = {
  getAllCookies,
  getNamedCookie,
  addCookie,
  deleteCookie,
  deleteAllCookies
};

其中一个函数的.?使用有问题,删了就可以运行,这个是js的一个正确语法,但是不知道为什么这里报错

candialala commented 1 year ago

你好,来信已收到~~我会尽快查收并回复的! XMU Software 陈晓娟    

yihuineng commented 1 year ago

Node 14 + 支持可选链操作符号(?.) 请升级node版本试一下