Macaca macaca java 脚本中第一个 byname 可以执行成功,第二个就提示失败,急!!!!!

mumu · 2018年10月15日 · 最后由 mumu 回复于 2018年10月15日 · 2185 次阅读

使用 mac 电脑测试 android,macaca-java 测试脚本中包含以下内容 :
driver.elementByName("我的").click();
driver.sleep(3000);

driver.elementByName("关于").click();
Thread.sleep(3000);

driver.elementByName("功能介绍").click();
Thread.sleep(3000);
现在每次执行都在第二个 byname 语句时执行失败,eclipse 日志:
2018-10-15 14:24:44 Request:http://localhost:3456/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:using":"name","value":"我的"}{"
2018-10-15 14:24:47 Response:{"status":0,"value":{"ELEMENT":"1"},"sessionId":null}
2018-10-15 14:24:47 Request:http://localhost:3456/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element/1/click:{}
2018-10-15 14:24:49 Response:{"status":0,"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e"}
2018-10-15 14:24:52 Request:http://localhost:3456/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:using":"name","value":"关于"}{"
2018-10-15 14:24:52 Response:BAD REQUEST: Syntax error. HTTP verb {}POST unhandled.
2018-10-15 14:24:52 Response:{"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e","status":0}

macaca server 日志:

UIAutomatorWD http server ready
macaca-android.js:303:10 [master] pid:2936 start app with: {"package":"com.dlxx.mam.gw","activity":""}
responseHandler.js:49:14 [master] pid:2936 Send HTTP Respone to Client[2018-10-15 14:24:41]: {"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e","status":0,"value":"{\"app\":\"/var/folders/fb/vqg8m_xd13902672dtrvw1jh0000gn/T/Robot-2.60.60-2018-10-12-15-21.apk\",\"proxyPort\":8910,\"reuse\":3,\"platformName\":\"android\",\"udid\":\"9963d01d\"}"}
responseHandler.js:11:12 [master] pid:2936 Recieve HTTP Request from Client[2018-10-15 14:24:44]: method: POST url: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element, jsonBody: {"using":"name","value":"我的"}
proxy.js:56:14 [master] pid:2936 Proxy: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:POST to http://127.0.0.1:9002/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:POST with body: {"using":"name","value":"我的"}
proxy.js:86:20 [master] pid:2936 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":null}
session.js:120:14 [master] pid:2936 Send HTTP Respone to Client[2018-10-15 14:24:47]: {"status":0,"value":"{\"ELEMENT\":\"1\"}","sessionId":null}
responseHandler.js:11:12 [master] pid:2936 Recieve HTTP Request from Client[2018-10-15 14:24:47]: method: POST url: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element/1/click, jsonBody: {}
proxy.js:56:14 [master] pid:2936 Proxy: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element/1/click:POST to http://127.0.0.1:9002/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element/1/click:POST with body: {}
proxy.js:86:20 [master] pid:2936 Got response with status 200: {"status":0,"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e"}
session.js:120:14 [master] pid:2936 Send HTTP Respone to Client[2018-10-15 14:24:49]: {"status":0,"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e"}
responseHandler.js:11:12 [master] pid:2936 Recieve HTTP Request from Client[2018-10-15 14:24:52]: method: POST url: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element, jsonBody: {"using":"name","value":"关于"}
proxy.js:56:14 [master] pid:2936 Proxy: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:POST to http://127.0.0.1:9002/wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e/element:POST with body: {"using":"name","value":"关于"}
proxy.js:77:24 [master] pid:2936 Fail to parse body: SyntaxError: Unexpected token B in JSON at position 0
proxy.js:86:20 [master] pid:2936 Got response with status 400: "BAD REQUEST: Syntax error. HTTP verb {}POST unhandled."
session.js:120:14 [master] pid:2936 Send HTTP Respone to Client[2018-10-15 14:24:52]: "BAD REQUEST: Syntax error. HTTP verb {}POST unhandled."
responseHandler.js:11:12 [master] pid:2936 Recieve HTTP Request from Client[2018-10-15 14:24:52]: method: DELETE url: /wd/hub/session/bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e, jsonBody: {}
session.js:91:12 [master] pid:2936 Delete session, sessionId: bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e
responseHandler.js:49:14 [master] pid:2936 Send HTTP Respone to Client[2018-10-15 14:24:52]: {"sessionId":"bbb5ebd6-ad33-4e17-a708-f2d0c9dd2e6e","status":0}

macaca 环境信息:
dlxxdeMacBook-Pro:~ dlxx$ macaca doctor

macaca-doctor version: 2.0.15

Node.js checklist:

node env: /usr/local/bin/node
node version: v8.12.0

iOS checklist:

Xcode Command Line Tools is ready, version: 2349.
xcodebuild version: 10.0
iproxy[usbmuxd] is installed at: /usr/local/bin/iproxy
ios_webkit_debug_proxy is installed at: /usr/local/bin/ios_webkit_debug_proxy

Android checklist:

JAVA version is 1.8
JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
ANDROID_HOME is set to /Users/dlxx/Library/Android/sdk
Platforms is set to /Users/dlxx/Library/Android/sdk/platforms/android-26
ADB tool is set to /Users/dlxx/Library/Android/sdk/platform-tools/adb
gradle is installed, version: 4.7

Installed driver list:

android: 2.0.46 [out-of-date]
chrome: 1.0.7
electron: 2.0.4
ios: 2.0.34

请问哪位大神有遇到过,如何破解这个问题,望赐教

附言 1  ·  2018年10月17日

同样的 macaca-cli 版本,macaca-android 版本,在 windows 电脑上是可以正常运行的,在 mac 电脑上运行失败

共收到 2 条回复 时间 点赞

如果你把 driver.sleep 缓存 Thread.sleep 呢

mumu #2 · 2018年10月15日 Author

我试试,还是一样的问题

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