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

yang · October 15, 2018 · Last by yang replied at October 15, 2018 · 1354 hits

使用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  ·  October 17, 2018

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

共收到 2 条回复 时间 点赞

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

yang #2 · October 15, 2018 作者

我试试,还是一样的问题

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up