Macaca [Help] macaca android 环境运行测试失败

金龙 · November 09, 2017 · Last by 张蜓婷🐈 replied at November 24, 2017 · 1126 hits

环境:

  • Android checklist:

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

Installed driver list:

android: 2.0.40

  • macaca-cli:2.0.12
  • node:v6.0.0
  • gradle:3.5

前两天正在写项目测试,不知道升级了什么,突然整个测试运行不了,现象是在启动应用后,滑动欢迎页报错,获取context是None

然后运行官方的实例macaca-android-sample,启动应用后,输入用户名、密码、正常,但无法点击“Login”

jinlong@bogon node_modules$ macaca server --verbose

index.js:18:12 [master] pid:84872 webdriver server start with config:
{ port: 3456,
verbose: true,
always: true,
ip: '192.168.3.43',
host: 'bogon',
loaded_time: '2017-11-09 17:58:59' }
middlewares.js:17:10 [master] pid:84872 base middlewares attached
router.js:133:10 [master] pid:84872 router set
webdriver sdk launched
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:01]: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"app":"https://npmcdn.com/android-app-bootstrap@latest/android_app_bootstrap/build/outputs/apk/android_app_bootstrap-debug.apk,platformName:android}"}
session.js:47:10 [master] pid:84872 Creating session, sessionId: d9a2153b-f9f1-41c2-ab5b-a6fd45d28417.
get /Users/jinlong/.macaca-temp/android_app_bootstrap-debug.apk from cache
sha:9656cdf14170f899681bebe9d58a1de4
helper.js:176:12 [master] pid:84872 Using local app form /Users/jinlong/.macaca-temp/android_app_bootstrap-debug.apk
uiautomator-client.js:61:14 [master] pid:84872 INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 1

uiautomator-client.js:61:14 [master] pid:84872 INSTRUMENTATION_STATUS: stream=
UIAutomatorWD->http://localhost:9005<-UIAutomatorWD
INSTRUMENTATION_STATUS_CODE: 0

UIAutomatorWD http server ready
macaca-android.js:294:10 [master] pid:84872 start app with: {"package":"com.github.android_app_bootstrap","activity":"com.github.android_app_bootstrap.activity.WelcomeActivity"}
responseHandler.js:49:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:20]: {"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417","status":0,"value":"{\"app\":\"/Users/jinlong/.macaca-temp/android_app_bootstrap-debug.apk\",\"platformName\":\"android\"}"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:20]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements, jsonBody: {"using":"class name","value":"android.widget.EditText"}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements:POST with body: {"using":"class name","value":"android.widget.EditText"}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"value":[{"ELEMENT":"1"},{"ELEMENT":"2"}],"sessionId":null}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:21]: {"status":0,"value":"[{\"ELEMENT\":\"1\"},{\"ELEMENT\":\"2\"}]","sessionId":null}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:21]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/value, jsonBody: {"value":["中文+Test+12345678"]}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/value:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/value:POST with body: {"value":["中文+Test+12345678"]}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:21]: {"status":0,"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:21]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements, jsonBody: {"using":"class name","value":"android.widget.EditText"}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/elements:POST with body: {"using":"class name","value":"android.widget.EditText"}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"value":[{"ELEMENT":"1"},{"ELEMENT":"2"}],"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:21]: {"status":0,"value":"[{\"ELEMENT\":\"1\"},{\"ELEMENT\":\"2\"}]","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:21]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/2/value, jsonBody: {"value":["111111"]}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/2/value:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/2/value:POST with body: {"value":["111111"]}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:21]: {"status":0,"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:21]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element, jsonBody: {"using":"id","value":"com.github.android_app_bootstrap:id/mobileNoEditText"}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element:POST with body: {"using":"id","value":"com.github.android_app_bootstrap:id/mobileNoEditText"}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:22]: {"status":0,"value":"{\"ELEMENT\":\"1\"}","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:22]: method: GET url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/displayed, jsonBody: {}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/displayed:GET to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/displayed:GET with body: {}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":0,"value":true,"sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:22]: {"status":0,"value":"true","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:22]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/click, jsonBody: {}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/click:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element/1/click:POST with body: {}
>> proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":13,"value":"An unknown server-side error occurred while processing the command.","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
session.js:109:14 [master] pid:84872 Send HTTP Respone to Client[2017-11-09 17:59:22]: {"status":13,"value":"\"An unknown server-side error occurred while processing the command.\"","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}
responseHandler.js:11:12 [master] pid:84872 Recieve HTTP Request from Client[2017-11-09 17:59:22]: method: POST url: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element, jsonBody: {"using":"name","value":"HOME"}
uiautomator-client.js:88:12 [master] pid:84872 get pids of com.macaca.android.testing failed, ignore this log
proxy.js:55:14 [master] pid:84872 Proxy: /wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element:POST to http://127.0.0.1:9005/wd/hub/session/d9a2153b-f9f1-41c2-ab5b-a6fd45d28417/element:POST with body: {"using":"name","value":"HOME"}
proxy.js:85:20 [master] pid:84872 Got response with status 200: {"status":32,"value":"Argument was an invalid selector (e.g. XPath/CSS).","sessionId":"d9a2153b-f9f1-41c2-ab5b-a6fd45d28417"}

最初以为是环境问题,所以重新安装了所有环境依赖,问题仍然存在,请大家帮忙看下原因。

共收到 1 条回复 时间 点赞

我也遇到了跟你一样的问题,请问解决了么

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