Macaca macaca-android 升级 2.0 后执行用例报错

whitiancai · 2017年05月09日 · 最后由 达峰的夏天 回复于 2017年05月16日 · 2591 次阅读

Macaca Version:1.2.3

Macaca Doctor Logs:
macaca-doctor version: 1.1.1

Node.js checklist:

node env: H:\nodejs\node.exe
node version: v6.10.0

Android checklist:

JAVA version is 1.8.0_101
JAVA_HOME is set to C:\Program Files\Java\jdk1.8.0_101
ANDROID_HOME is set to D:\sdk
Platforms is set to D:\sdk\platforms\android-25
Android tools is set to D:\sdk\tools\android.bat
ADB tool is set to D:\sdk\platform-tools\adb.exe
GRADLE_HOME is set to C:\Users\huangjianbo.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9\gradle-3.3

Installed driver list:

android: 2.0.0

Operate System:win 7 64bit

Programming Language:nodeJs

升级 macaca-android 2.0 版本后,执行用例直接报错。

webdriver sdk launched

[ 'macaca-test/wx_chat.test.js', '--colors', '--verbose' ]

(node:9560) DeprecationWarning: DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/vMUyr)

给某人的发消息

androidOpts:{ platformName: 'Android',
autoAcceptAlerts: true,
reuse: 2,
udid: 'SODMDIQ499999999',
package: 'com.tencent.mm',
activity: '.ui.LauncherUI',
androidProcess: undefined }

1) "before all" hook

2) "after all" hook

0 passing (7s)

2 failing

1) 给某人的发消息 "before all" hook:
Error: [init({"platformName":"Android","autoAcceptAlerts":true,"reuse":2,"udid":"SODMDIQ499999999","package":"com.tencent.mm","activity":".ui.LauncherUI"})] The environment you requested was unavailable.
at node_modules\macaca-wd\wd\lib\webdriver.js:134:15
at Request._callback (node_modules\macaca-wd\wd\lib\http-utils.js:87:7)
at Request.self.callback (node_modules\macaca-wd\node_modules\request\request.js:368:22)
at Request. (node_modules\macaca-wd\node_modules\request\request.js:1219:14)
at IncomingMessage. (node_modules\macaca-wd\node_modules\request\request.js:1167:12)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

2) 给某人的发消息 "after all" hook:
Error: [quit()] Unexpected data in simpleCallback.
at exports.newError (node_modules\macaca-wd\wd\lib\utils.js:139:13)
at . (node_modules\macaca-wd\wd\lib\callbacks.js:42:12)
at cb (node_modules\macaca-wd\wd\lib\webdriver.js:165:22)
at node_modules\macaca-wd\wd\lib\webdriver.js:179:5
at Request._callback (node_modules\macaca-wd\wd\lib\http-utils.js:87:7)
at Request.self.callback (node_modules\macaca-wd\node_modules\request\request.js:368:22)
at Request. (node_modules\macaca-wd\node_modules\request\request.js:1219:14)
at IncomingMessage. (node_modules\macaca-wd\node_modules\request\request.js:1167:12)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

Test completed!

报错:Error: Command failed: D:\sdk/platform-tools/adb -s SODMDIQ499999999 push d:\NodeProjects\AutoMobile\node_modules\uiautomatorwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/undefined

查看源码在 uiautomatorwd.js 发现缺少 CLASS_NAME,在 uiautomator-client.js 中调用 ${UIAUTOMATORWD.CLASS_NAME}显示 undefined。
而且 UIAUTOMATORWD.APK_BUILD_PATH 显示的 apk 路径不存在,是需要自己手动编译?

@xdf

共收到 10 条回复 时间 点赞


下载的栗子错误,什么原因呀

liubin 回复

你这个没找到 mocha,你看看你的 node_modules 里有没有 mocha 库

感谢帮助

昨天才开始接触的,不知道截图对不对,麻烦啦

whitiancai 回复

是 npm 目录下的吗?不知道我截图对不对

liubin 回复

你报错是 D>TestStudioProjects>macaca-android>test>node_modules 啊,你应该去这个目录下看,你发的截图不是这个目录

whitiancai 回复


这 test 目录下没有 node_modules 这,不过在上层有这目录

1 保证 android-sdk build-tools 25.0.2 安装 android support repository
2 gradle 配置正常

3 npm uninstall macaca-android -g
npm cache clean
cd /tmp
sudo rm -rf npm*

4 再 npm i macaca-android -g 保证安装日志都是 build successful

5 保证 安装完 macaca-android 后 有这个文件 node-global\node_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-debug.apk

6 再安装 app-inspector 就 OK 了

详见 https://github.com/alibaba/macaca/issues/550

@liubin_5288 不要在包含测试文件的这个目录下执行 macaca 命令,在根目录下执行就可以(包含 node_modules 的目录)。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册