Macaca win10 环境 Macaca Python 尝试

小马 · September 11, 2017 · Last by 刘刘刘 replied at April 25, 2018 · 3768 hits

该文为macaca的python版本
macaca python版本 https://github.com/macacajs/wd.py

一 基本环境安装

macaca相关基础

1.1 安装配置Oracle java

下载地址 http://www.oracle.com/technetwork/java/javase/downloads/index.html
找到合适的java版本下载,我选择的是jdk-8u121-windows-x64.exe。按步骤安装即可。安装路径一般默认。

配置java 环境变量:
JAVA_HOME 变量值为JDK的安装目录,笔者为C:\Program Files\Java\jdk1.8.0_121
PATH PATH变量值后追加 ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
CLASSPATH 变量值为 ;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

检查是否安装成功

C:\Users\cmd>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

1.2 安装配置Android SDK

下载地址 http://tools.android-studio.org/index.php/sdk 处下载 android-sdk_r24.4.1-windows.zip
将android-sdk-windows解压到你需要的目录下,笔者是D:\Android\android-sdk-windows

配置android-sdk环境变量:
ANDROID_HOME 变量值为android-sdk的解压目录,笔者为D:\Android\android-sdk-windows
PATH PATH变量值的最后追加 ;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\build-tools;

接下来你便可以用D:\Android\android-sdk-windows 下的SDK Manager.exe下载配置SDK 或AVD Manager.exe 配置 AVD模拟器了。
此处不多讲了,如果你需要测试macaca支持的android应用的话,请先安装配置好某一版本的SDK及其相关工具。

win10 测试安卓应用的话目前我的配置是:


关于Android开发环境的大家可以参考此人的博客

Android SDK Manager和AVD Manager使用

Android开发环境配置

AVD模拟器有些慢,我一般用的都是Genymotion 请参考http://www.iplaysoft.com/genymotion.html 自行安装配置。

1.3安装配置nodejs

1.3.1 安装nodejsv6.10.0 LTS稳定版

去官网 https://nodejs.org/en/ 下载 v6.10.0 LTS 这个稳定版本,也就是node-v6.10.0-x64.msi这个。
然后安装到本地 D:\nodejs
刚安装完是这样的版本

 C:\Users\cmd>node -v
v6.10.0

C:\Users\cmd>npm -v
3.10.10

PS:node 的版本最好就用 LTS 这个长期技术支持稳定版本,其他版本会有问题。
npm 的版本无所谓,你升级到最新的npm 3.10.10 弄macaca也不会有什么问题。

1.3.2 添加PATH环境变量

追加到PATH之后便可以了,D:\nodejs;D:\nodejs\node-global

1.3.3 nodejs的配置设置

去D:\nodejs\目录下,新建 node-global 和 node-cache。先看下 如果已经有了 就不用再新建了。


C:\Users\cmd>npm config set prefix "D:\nodejs\node-global"
C:\Users\cmd>npm config set cache "D:\nodejs\node-cache"

检查下是否设置成功

C:\Users\cmd>npm config get prefix
D:\nodejs\node-global
C:\Users\cmd>npm config get cache
D:\nodejs\node-cache

再检查下安装源,我应该所有的安装源都是taobao.org,安装源有问题的话

 npm config set  registry http://registry.npm.taobao.org
C:\Users\cmd>npm config get registry
http://registry.npm.taobao.org

PS: 推荐尽量用国内的淘宝镜像源,因为你懂得的原因某些组件需要国外服务器下载,下载会失败导致macaca相关安装失败。

1.4 安装配置gradle

macaca最新的采用了gradle来构建和部署(以前有依赖Apache ant构建)。所以我们需要安装配置gradle。
详见官方帮助 https://gradle.org/install 来部署安装好gradle。

见到如下输出就说明gradle配置正确了:
win10如下

C:\Users\cmd>gradle -v

------------------------------------------------------------
Gradle 3.5
------------------------------------------------------------

Build time: 2017-04-10 13:37:25 UTC
Revision: b762622a185d59ce0cfc9cbc6ab5dd22469e18a6

Groovy: 2.4.10
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_121 (Oracle Corporation 25.121-b13)
OS: Windows 10 10.0 amd64

1.5 安装macaca相关

然后就是安装macaca-cli 和各种macaca驱动
npm i macaca-cli -g
npm i macaca-electron -g
npm i macaca-chrome -g
npm i macaca-android -g

最后 macaca doctor检查环境

C:\Users\cmd>macaca doctor

macaca-doctor version: 2.0.2


Node.js checklist:

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

Android checklist:

JAVA version is `1.8.0_121`
JAVA_HOME is set to `C:\Program Files\Java\jdk1.8.0_121`
ANDROID_HOME is set to `D:\Android\android-sdk-windows`
Platforms is set to `D:\Android\android-sdk-windows\platforms\android-25`
ADB tool is set to `D:\Android\android-sdk-windows\platform-tools\adb.exe`
GRADLE_HOME is set to `D:\gradle-3.5`

Installed driver list:

android: 2.0.36
chrome: 1.0.6
electron: 1.1.11

python相关基础

官网下载最新的python3 我下的是python-3.6.2.exe 直接安装。
设置环境变量
PATH PATH变量值后追加 D:\python\;D:\python\Scripts

检查python -v 查看是否安装正确 后exit() 退出 python环境

二 sample-python样例

2.1 下载样例

D:\>cd macaca

D:\macaca>git clone https://github.com/macaca-sample/sample-python

2.2 安装Macaca Python Client

地址 https://pypi.python.org/pypi/wd 也可如下命令安装

D:\macaca\sample-python\tests>python -m pip install wd
Collecting wd
Downloading wd-0.1.10-py3-none-any.whl
Requirement already satisfied: retrying in d:\python\lib\site-packages (from wd)
Requirement already satisfied: enum34 in d:\python\lib\site-packages (from wd)
Requirement already satisfied: requests in d:\python\lib\site-packages (from wd)
Requirement already satisfied: six>=1.7.0 in d:\python\lib\site-packages (from retrying->wd)
Installing collected packages: wd
Successfully installed wd-0.1.10

2.3 在安装下样例依赖
这步应该和上步骤重复都是wd.py环境安装,您可选择一种方式

D:\macaca\sample-python>pip install -r requirements.txt
Requirement already satisfied: wd in d:\python\lib\site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: retrying in d:\python\lib\site-packages (from -r requirements.txt (line 2))
Requirement already satisfied: requests in d:\python\lib\site-packages (from wd->-r requirements.txt (line 1))
Requirement already satisfied: enum34 in d:\python\lib\site-packages (from wd->-r requirements.txt (line 1))
Requirement already satisfied: six>=1.7.0 in d:\python\lib\site-packages (from retrying->-r requirements.txt (line 2))
Cache entry deserialization failed, entry ignored

三 执行样例

3.1 启动macaca server

C:\Users\cmd>macaca server -p 3456 --verbose
>> index.js:18:12 [master] pid:18312 webdriver server start with config:
{ port: 3456,
verbose: true,
always: true,
ip: '*.*.68.*',
host: 'cmd',
loaded_time: '2017-09-11 14:33:28' }
>> middlewares.js:17:10 [master] pid:18312 base middlewares attached
>> router.js:127:10 [master] pid:18312 router set
>> webdriver sdk launched

3.2 命令执行测试脚本

D:\macaca\sample-python>python tests/macaca-desktop-sample.test.py
也可 继续 cd tests到脚本目录D:\macaca\sample-python\tests>下执行 python macaca-desktop-sample.test.py

desktop 依赖electron

如果跑android脚本 需要启动一安卓模拟器比如genymotion 再同理执行 D:\macaca\sample-python\tests>python macaca-android-sample.test.py

默认不改动的macaca-android-sample.test.py 貌似有问题 python执行命令行 会显示 Retry connecting server... 然后macaca server 命令行一直在

>> start to download: https://npmcdn.com/android-app-bootstrap@latest/android_app_bootstrap/build/outputs/apk/android_app_bootstrap-debug.apk  

并无后续响应,停在这儿一直不走了。

单独访问该下载地址又是可以直接下载下来的,于是我将该段下载测试apk的代码 改为如下:即直接访问链接下载到本地某一位置。

desired_caps = {
'platformName': 'android',
'app': 'D:\\Install\\apk\\android_app_bootstrap-debug.apk',
}

最后在执行 测试通过

最后再尝试新建一自家apk测试

import unittest
import os
import time
from macaca import WebDriver

desired_caps = {
'platformName': 'android',
'app': 'D:\\Install\\apk\\****.apk',
'reuse': 3
}

server_url = {
'hostname': 'localhost',
'port': 3456
}


class MacacaTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = WebDriver(desired_caps, server_url)
cls.driver.init()

@classmethod
def tearDownClass(cls):
cls.driver.quit()

def test_01_login(self):

self.driver \
.element_by_id('com.acp.main:id/tvBottomTab4') \
.click()

time.sleep(5)

self.driver\
.element_by_id('com.acp.main:id/layoutLogin')\
.click()

time.sleep(5)

self.driver\
.element_by_id('com.acp.aicaitencent:id/etUserName')\
.send_keys('********')

time.sleep(5)

self.driver\
.element_by_id('com.acp.aicaitencent:id/etPwd')\
.send_keys('*******')

time.sleep(5)

self.driver\
.element_by_id('com.acp.aicaitencent:id/tvLogin')\
.click()

time.sleep(5)

if __name__ == '__main__':
unittest.main()

测试通过

以上为本日9月11日中午休息 尝试python 版本的macaca记录

更多信息请参考wiki汇总

小马的macaca入门指引合集

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 18 条回复 时间 点赞

还是这么复杂

楼主,你好,能否帮忙看下,执行同样的安卓用例,报以下错误

UIAutomatorWD http server ready

proxy.js:55:14 [master] pid:18500 Proxy: /wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element:POST to http://127.0.0.1:9001/wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element:POST with body: {"using":"name","value":"HO
ME"}

proxy.js:85:20 [master] pid:18500 Got response with status 200: {"status":32,"value":"Argument was an invalid selector (e.g. XPath/CSS).","sessionId":"4c70c99a-437c-41fa-9a4c-ebf084fa17c7"}

session.js:109:14 [master] pid:18500 Send HTTP Respone to Client[2017-10-16 20:56:09]: {"status":32,"value":"\"Argument was an invalid selector (e.g. XPath/CSS).\"","sessionId":"4c70c99a-437c-41fa-9a4c-ebf084fa17c7"}

responseHandler.js:11:12 [master] pid:18500 Recieve HTTP Request from Client[2017-10-16 20:56:14]: method: POST url: /wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element, jsonBody: {"using":"name","value":"Alert"}

restart UIAutomatorWD server

uiautomator-client.js:61:14 [master] pid:18500 INSTRUMENTATION_RESULT: shortMsg=Process crashed.

INSTRUMENTATION_CODE: 0

uiautomator-client.js:61:14 [master] pid:18500 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:18500 INSTRUMENTATION_STATUS: stream=

UIAutomatorWD->http://localhost:9001<-UIAutomatorWD

INSTRUMENTATION_STATUS_CODE: 0

UIAutomatorWD http server ready

proxy.js:55:14 [master] pid:18500 Proxy: /wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element:POST to http://127.0.0.1:9001/wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element:POST with body: {"using":"name","value":"Al
ert"}

proxy.js:85:20 [master] pid:18500 Got response with status 200: {"status":32,"value":"Argument was an invalid selector (e.g. XPath/CSS).","sessionId":"4c70c99a-437c-41fa-9a4c-ebf084fa17c7"}

session.js:109:14 [master] pid:18500 Send HTTP Respone to Client[2017-10-16 20:56:16]: {"status":32,"value":"\"Argument was an invalid selector (e.g. XPath/CSS).\"","sessionId":"4c70c99a-437c-41fa-9a4c-ebf084fa17c7"}

responseHandler.js:11:12 [master] pid:18500 Recieve HTTP Request from Client[2017-10-16 20:56:17]: method: POST url: /wd/hub/session/4c70c99a-437c-41fa-9a4c-ebf084fa17c7/element, jsonBody: {"using":"name","value":"Alert"}

restart UIAutomatorWD server

uiautomator-client.js:61:14 [master] pid:18500 INSTRUMENTATION_RESULT: shortMsg=Process crashed.

INSTRUMENTATION_CODE: 0

uiautomator-client.js:61:14 [master] pid:18500 java.lang.SecurityException: Calling from not trusted UID!

at android.app.UiAutomationConnection.throwIfCalledByNotTrustedUidLocked(UiAutomationConnection.java:376)

at android.app.UiAutomationConnection.shutdown(UiAutomationConnection.java:275)

at android.app.IUiAutomationConnection$Stub.onTransact(IUiAutomationConnection.java:118)

at android.os.Binder.execTransact(Binder.java:455)

uiautomator-client.js:61:14 [master] pid:18500 java.lang.SecurityException: Calling from not trusted UID!

at android.os.Parcel.readException(Parcel.java:1546)

at android.os.Parcel.readException(Parcel.java:1499)

at android.app.ActivityManagerProxy.startInstrumentation(ActivityManagerNative.java:3913)

at com.android.commands.am.Am.runInstrument(Am.java:976)

at com.android.commands.am.Am.onRun(Am.java:317)

at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)

at com.android.commands.am.Am.main(Am.java:97)

at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)

at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:284)

以上问题已解决,目前使用安卓7.0设备已跑通样例,好艰难

感觉很赞,写的非常细,开工,按你的来开搞~

ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:23]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 0c5951d8-76
f4-4a92-b1d6-038cd2011d5c.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:24]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 96857dd9-fe
1b-4503-b6ab-ce1300065ffd.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:25]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: c6b0d50d-4e
20-4b58-8ab7-9237303ddadf.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:26]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: bc2a70af-6f
e2-4ca2-b56f-e1a645ad007a.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:27]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: aefaade2-ef
83-4ef9-b694-de7d2562c7f8.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:28]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 80784b7a-0a
da-4ce6-af8c-c24fbe827d4e.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:29]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 65497acc-4c
7d-4792-98f0-fa650e069b41.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:30]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 3fdea234-ed
38-4f71-9864-6b1e28f771c2.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
>> responseHandler.js:56:12 [master] pid:140316 Send Error Respone to Client: Er
ror: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:5555 p
ush D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd
\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing

>> responseHandler.js:62:14 [master] pid:140316 Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: Command failed: D:\Android\sdk/platform-tools/adb -s 192.168.187.101:55
55 push D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomat
orwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.test
ing

at ChildProcess.exithandler (child_process.js:204:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:891:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

>> responseHandler.js:11:12 [master] pid:140316 Recieve HTTP Request from Client
[2017-10-20 10:47:31]: method: POST url: /wd/hub/session, jsonBody: {"desiredCap
abilities"
:{"app":"E:\\apk_Macaca\\android_app_bootstrap-debug.apk","platformNam
e"
:"android"}}
>> session.js:47:10 [master] pid:140316 Creating session, sessionId: 3c6b6551-68
e2-4546-9019-772cc7bf5768.
>> helper.js:208:12 [master] pid:140316 Using local app form E:\apk_Macaca\andro
id_app_bootstrap-debug.apk
^C终止批处理操作吗(Y/N)? y

D:\nodejs\node-global>

@harsayer
求问,一直卡在retry conecting server..(我已经按照你的把apk下载到本来,并修改了路径),我看了他的adb命令,按照他的路径找,没有找到对应的包,感觉是不是没有生成成功??

@jierong01
Error: Command failed: D:\Androi
d\sdk/platform-tools/adb -s 192.168.187.101:5555 push D:\nodejs\node-global\node
_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testin

应该是你的 macaca-android 驱动没安装好 这个路径下 有这个文件吗 app-deb
ug.apk 没有就是编译macaca-android的时候 没成功,安装完要看日志 要保证全部 build sucessful的字样

最新的 app-inspector 2.0.8 和macaca-android 2.0.40 需要Android SDK Build-tools 25.0.2
Android SDK Platform-tools 26.0.1和Extras下的Android Support Repository 47
还有需要android sdk Platform (API 26)

小马 回复

非常感谢你的回答,那我按你的搞搞

安装的adnroid驱动:

使用macaca doctor的检测:

@harsayer
我查看一下D:\nodejs\node-global\node_modules\macaca-android\node_modules\uiautomatorwd\app\build\outputs\apk\app-deb
ug.apk /data/local/tmp/com.macaca.android.testin 这个路径下面的东西,还时没有这个文件,难道驱动没有安装成功么??也没提示我失败啊。就是你说的,没有app-debug.apk 这个

jierong01 回复

npm uninstall macaca-android -g
npm uninstall app-inspector -g
npm cache clean
同时可以清理下下载缓存目录:
win10 在 C:\Users\your name\AppData\Local\Temp 下 手动删除npm开头相关即可
ubuntu16.04 在 /tmp下 sudo rm -rf npm* 即可
再安装 你这日志 一看就是 覆盖安装的 有脏东西

要番 羽 墙的 或者***的 简单的话 开启中国移动4G卡 wifi热点 电脑只连该热点 再npm i

小马 回复
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD
INSTRUMENTATION_STATUS_CODE: 0

>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Ale
rt"
}
>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:26]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:27]: method: POST url: /wd/hub/session/9a770030-8647-4845-a38e
-59533a1bf653/element, jsonBody: {"using":"name","value":"Alert"}
>> restart UIAutomatorWD server
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_RESULT: short
Msg=Process crashed.
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_CODE: 0

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: id=An
droidJUnitRunner

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: curre
nt=1
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS_CODE: 1

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: strea
m=
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD
>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Ale
rt"
}
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_STATUS_CODE: 0

>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:29]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:30]: method: POST url: /wd/hub/session/9a770030-8647-4845-a38e
-59533a1bf653/element, jsonBody: {"using":"name","value":"Alert"}
>> restart UIAutomatorWD server
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_RESULT: short
Msg=Process crashed.
INSTRUMENTATION_CODE: 0

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: id=An
droidJUnitRunner

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: curre
nt=1
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS_CODE: 1

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: strea
m=
>> uiautomator-client.js:61:14 [master] pid:154912
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD
INSTRUMENTATION_STATUS_CODE: 0

>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Ale
rt"
}
>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:33]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:33]: method: POST url: /wd/hub/session/9a770030-8647-4845-a38e
-59533a1bf653/element, jsonBody: {"using":"name","value":"Webview"}
>> restart UIAutomatorWD server
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_RESULT: short
Msg=Process crashed.
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_CODE: 0

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: id=An
droidJUnitRunner
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS_CODE: 1

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: strea
m=
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD
>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Web
view"
}
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_STATUS_CODE: 0

>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:36]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:37]: method: POST url: /wd/hub/session/9a770030-8647-4845-a38e
-59533a1bf653/element, jsonBody: {"using":"name","value":"Webview"}
>> restart UIAutomatorWD server
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_RESULT: short
Msg=Process crashed.
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_CODE: 0

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: id=An
droidJUnitRunner
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: numtests=1
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS_CODE: 1

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: strea
m=
>> uiautomator-client.js:61:14 [master] pid:154912
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD

>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Web
view"
}
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS_CODE:
0

>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:39]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:40]: method: POST url: /wd/hub/session/9a770030-8647-4845-a38e
-59533a1bf653/element, jsonBody: {"using":"name","value":"Webview"}
>> restart UIAutomatorWD server
>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_RESULT: short
Msg=Process crashed.
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_CODE: 0

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: id=An
droidJUnitRunner

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: curre
nt=1
INSTRUMENTATION_STATUS: class=com.macaca.android.testing.UIAutomatorWD
INSTRUMENTATION_STATUS: stream=
com.macaca.android.testing.UIAutomatorWD:
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: test=MacacaTestRunner
INSTRUMENTATION_STATUS_CODE: 1

>> uiautomator-client.js:61:14 [master] pid:154912 INSTRUMENTATION_STATUS: strea
m=
UIAutomatorWD->http://localhost:9001<-UIAutomatorWD
>> UIAutomatorWD http server ready
>> proxy.js:55:14 [master] pid:154912 Proxy: /wd/hub/session/9a770030-8647-4845-
a38e-59533a1bf653/element:POST to http://127.0.0.1:9001/wd/hub/session/9a770030-
8647-4845-a38e-59533a1bf653/element:POST with body: {"using":"name","value":"Web
view"
}
>> uiautomator-client.js:61:14 [master] pid:154912
INSTRUMENTATION_STATUS_CODE: 0

>> proxy.js:85:20 [master] pid:154912 Got response with status 200: {"sessionId"
:"9a770030-8647-4845-a38e-59533a1bf653","status":32,"value":"Argument was an inv
alid selector (e.g. XPath/CSS)."
}
>> session.js:109:14 [master] pid:154912 Send HTTP Respone to Client[2017-10-20
14:54:43]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":32,"valu
e"
:"\"Argument was an invalid selector (e.g. XPath/CSS).\""}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:54:43]: method: GET url: /wd/hub/session/9a770030-8647-4845-a38e-
59533a1bf653/contexts, jsonBody: {}
>> No webview version found from adb shell!
>> use default chromedriver version!
>> starting chromedriver service!
>> chromedriver bin path: D:\nodejs\node-global\node_modules\macaca-android\node
_modules\macaca-chromedriver\exec\chromedriver2.20.exe
>> Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067)
on port 9515
Only local connections are allowed.

>> chromedriver starting success.
>> proxy.js:51:14 [master] pid:154912 Proxy: /status:GET to http://localhost:951
5/wd/hub/status:GET with body:
>> proxy.js:59:16 [master] pid:154912 Got response with status 200: "{\"sessionI
d\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arc
h\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.1 SP1\"}}}"

>> proxy.js:51:14 [master] pid:154912 Proxy: /session:POST to http://localhost:9
515/wd/hub/session:POST with body: {"desiredCapabilities":{"chromeOptions":{"and
roidPackage"
:"com.github.android_app_bootstrap","androidUseRunningApp":true,"and
roidDeviceSerial"
:"686f4b0c"}}}
>> proxy.js:59:16 [master] pid:154912 Got response with status 200: {"sessionId"
:"c42b29351b37f6767c4c761e5ab6f306","status":100,"value":{"message":"chrome not
reachable\n (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf70
81628a1396067),platform=W...
>> chromedriver ready with: {"
sessionId":null,"status":100,"value":{"message":"c
hrome not reachable\n (Driver info: chromedriver=2.20.353145 (343b531d31eeb933e
c778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)"}}
>> proxy.js:51:14 [master] pid:154912 Proxy: /wd/hub/session/:sessionId/window_h
andles:GET to http://localhost:9515/wd/hub/session/c42b29351b37f6767c4c761e5ab6f
306/window_handles:GET with body: {}
>> proxy.js:59:16 [master] pid:154912 Got response with status 200: {"
sessionId"
:"
c42b29351b37f6767c4c761e5ab6f306","status":6,"value":{"message":"no such sessi
on\n (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1
396067),platform=Windows ...
>> responseHandler.js:56:12 [master] pid:154912 Send Error Respone to Client: No
SuchDriver: no such session
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a13960
67),platform=Windows NT 6.1 SP1 x86_64)
>> responseHandler.js:62:14 [master] pid:154912 NoSuchDriver: no such session
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a13960
67),platform=Windows NT 6.1 SP1 x86_64)
at Object._.parseWebDriverResult (D:\nodejs\node-global\node_modules\macaca-
android\lib\helper.js:72:11)
at Android.getWebviews (D:\nodejs\node-global\node_modules\macaca-android\li
b\macaca-android.js:327:16)
at next (native)
at onFulfilled (D:\nodejs\node-global\node_modules\macaca-cli\node_modules\c
o\index.js:65:19)
at process._tickCallback (internal/process/next_tick.js:109:7)
>> responseHandler.js:78:14 [master] pid:154912 Send Bad HTTP Respone to Client[
2017-10-20 14:55:47]: {"sessionId":"9a770030-8647-4845-a38e-59533a1bf653","statu
s"
:6,"value":{"message":"no such session\n (Driver info: chromedriver=2.20.3531
45 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64
)"
}}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:55:47]: method: GET url: /wd/hub/session/9a770030-8647-4845-a38e-
59533a1bf653/contexts, jsonBody: {}
>> proxy.js:51:14 [master] pid:154912 Proxy: /wd/hub/session/:sessionId/window_h
andles:GET to http://localhost:9515/wd/hub/session/c42b29351b37f6767c4c761e5ab6f
306/window_handles:GET with body: {}
>> proxy.js:59:16 [master] pid:154912 Got response with status 200: {"sessionId"
:"c42b29351b37f6767c4c761e5ab6f306","status":6,"value":{"message":"no such sessi
on\n (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1
396067),platform=Windows ...
>> responseHandler.js:56:12 [master] pid:154912 Send Error Respone to Client: No
SuchDriver: no such session
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a13960
67),platform=Windows NT 6.1 SP1 x86_64)
>> responseHandler.js:62:14 [master] pid:154912 NoSuchDriver: no such session
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a13960
67),platform=Windows NT 6.1 SP1 x86_64)
at Object._.parseWebDriverResult (D:\nodejs\node-global\node_modules\macaca-
android\lib\helper.js:72:11)
at Android.getWebviews (D:\nodejs\node-global\node_modules\macaca-android\li
b\macaca-android.js:327:16)
at next (native)
at onFulfilled (D:\nodejs\node-global\node_modules\macaca-cli\node_modules\c
o\index.js:65:19)
at process._tickCallback (internal/process/next_tick.js:109:7)
>> responseHandler.js:78:14 [master] pid:154912 Send Bad HTTP Respone to Client[
2017-10-20 14:55:47]: {"
sessionId":"9a770030-8647-4845-a38e-59533a1bf653","statu
s":6,"value":{"message":"no such session\n (Driver info: chromedriver=2.20.3531
45 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64
)"}}
>> responseHandler.js:11:12 [master] pid:154912 Recieve HTTP Request from Client
[2017-10-20 14:55:47]: method: DELETE url: /wd/hub/session/9a770030-8647-4845-a3
8e-59533a1bf653, jsonBody: {}
>> session.js:80:12 [master] pid:154912 Delete session, sessionId: 9a770030-8647
-4845-a38e-59533a1bf653
>> responseHandler.js:49:14 [master] pid:154912 Send HTTP Respone to Client[2017
-10-20 14:55:47]: {"
sessionId":"9a770030-8647-4845-a38e-59533a1bf653","status":0
}
>> macaca-chromedriver.js:168:18 [master] pid:154912 chromedriver exit with code
: null, signal: SIGTERM

@harsayer
已经可以安装上官方的app了,但是只是启动了起来,并没有跑起来,这是为什么(就是安装上了,启动了app打开了activity,但具体操作没有触发),看了日志,显示 Send Error Respone to Client,这个要怎么弄。自己都有点脸红了,老是伸手党,可网上资料实在太少。

@harsayer
换了一部android 8.0的机子可以跑起来了,但是为什么android 4.3的机子,竟然没有跑起来???问了一下qq群的人,他们说5.1的也没有跑起来,6.0以上就可以,这样有点尴尬~感谢你的指导,谢谢

小马 #11 · October 20, 2017 作者
jierong01 回复

日志 已经告诉你了 macaca-chromedriver 的事 不同的chromedriver 能驱动带起来的浏览器版本 是不一样的 。 可以 自己制chromedriver版本 。https://testerhome.com/topics/6233 参考。

>> No webview version found from adb shell!
>> use default chromedriver version!
>> starting chromedriver service!
>> chromedriver bin path: D:\nodejs\node-global\node_modules\macaca-android\node
_modules\macaca-chromedriver\exec\chromedriver2.20.exe
>> Starting ChromeDriver 2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b)
on port 9516
Only local connections are allowed.

>> chromedriver starting success.
>> proxy.js:51:14 [master] pid:123744 Proxy: /status:GET to http://localhost:951
6/wd/hub/status:GET with body:
>> proxy.js:59:16 [master] pid:123744 Got response with status 200: "{\"sessionI
d\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arc
h\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.1.7601 SP1\"}}}"

>> proxy.js:51:14 [master] pid:123744 Proxy: /session:POST to http://localhost:9
516/wd/hub/session:POST with body: {"desiredCapabilities":{"chromeOptions":{"and
roidPackage"
:"com.github.android_app_bootstrap","androidUseRunningApp":true,"and
roidDeviceSerial"
:"ENU7N15B10002359"}}}
>> proxy.js:59:16 [master] pid:123744 Got response with status 200: {"sessionId"
:"081760a5bd6948c9d8b97d74c2051f50","status":100,"value":{"message":"chrome not
reachable\n (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1
943c01833cc1b),platform=W...
>> chromedriver ready with: {"
sessionId":null,"status":100,"value":{"message":"c
hrome not reachable\n (Driver info: chromedriver=2.22.397933 (1cab651507b88dec7
9b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
>> proxy.js:51:14 [master] pid:123744 Proxy: /wd/hub/session/:sessionId/window_h
andles:GET to http://localhost:9516/wd/hub/session/081760a5bd6948c9d8b97d74c2051
f50/window_handles:GET with body: {}
>> proxy.js:59:16 [master] pid:123744 Got response with status 200: {"
sessionId"
:"
081760a5bd6948c9d8b97d74c2051f50","status":6,"value":{"message":"no such sessi
on\n (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c018
33cc1b),platform=Windows ...
>> responseHandler.js:56:12 [master] pid:123744 Send Error Respone to Client: No
SuchDriver: no such session
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc
1b),platform=Windows NT 6.1.7601 SP1 x86_64)
>> responseHandler.js:62:14 [master] pid:123744 NoSuchDriver: no such session
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc
1b),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object._.parseWebDriverResult (D:\nodejs\node-global\node_modules\macaca-
android\lib\helper.js:72:11)
at Android.getWebviews (D:\nodejs\node-global\node_modules\macaca-android\li
b\macaca-android.js:327:16)
at next (native)
at onFulfilled (D:\nodejs\node-global\node_modules\macaca-cli\node_modules\c
o\index.js:65:19)
at process._tickCallback (internal/process/next_tick.js:109:7)
>> responseHandler.js:78:14 [master] pid:123744 Send Bad HTTP Respone to Client[
2017-10-20 17:54:02]: {"sessionId":"06b85ea6-84c3-427a-8211-101f1c3ae587","statu
s"
:6,"value":{"message":"no such session\n (Driver info: chromedriver=2.22.3979
33 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x
86_64)"
}}
>> responseHandler.js:11:12 [master] pid:123744 Recieve HTTP Request from Client
[2017-10-20 17:54:02]: method: GET url: /wd/hub/session/06b85ea6-84c3-427a-8211-
101f1c3ae587/contexts, jsonBody: {}
>> proxy.js:51:14 [master] pid:123744 Proxy: /wd/hub/session/:sessionId/window_h
andles:GET to http://localhost:9516/wd/hub/session/081760a5bd6948c9d8b97d74c2051
f50/window_handles:GET with body: {}
>> proxy.js:59:16 [master] pid:123744 Got response with status 200: {"sessionId"
:"081760a5bd6948c9d8b97d74c2051f50","status":6,"value":{"message":"no such sessi
on\n (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c018
33cc1b),platform=Windows ...
>> responseHandler.js:56:12 [master] pid:123744 Send Error Respone to Client: No
SuchDriver: no such session
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc
1b),platform=Windows NT 6.1.7601 SP1 x86_64)
>> responseHandler.js:62:14 [master] pid:123744 NoSuchDriver: no such session
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc
1b),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object._.parseWebDriverResult (D:\nodejs\node-global\node_modules\macaca-
android\lib\helper.js:72:11)
at Android.getWebviews (D:\nodejs\node-global\node_modules\macaca-android\li
b\macaca-android.js:327:16)
at next (native)
at onFulfilled (D:\nodejs\node-global\node_modules\macaca-cli\node_modules\c
o\index.js:65:19)
at process._tickCallback (internal/process/next_tick.js:109:7)
>> responseHandler.js:78:14 [master] pid:123744 Send Bad HTTP Respone to Client[
2017-10-20 17:54:02]: {"
sessionId":"06b85ea6-84c3-427a-8211-101f1c3ae587","statu
s":6,"value":{"message":"no such session\n (Driver info: chromedriver=2.22.3979
33 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x
86_64)"}}
>> responseHandler.js:11:12 [master] pid:123744 Recieve HTTP Request from Client
[2017-10-20 17:54:02]: method: DELETE url: /wd/hub/session/06b85ea6-84c3-427a-82
11-101f1c3ae587, jsonBody: {}
>> session.js:80:12 [master] pid:123744 Delete session, sessionId: 06b85ea6-84c3
-427a-8211-101f1c3ae587
>> responseHandler.js:49:14 [master] pid:123744 Send HTTP Respone to Client[2017
-10-20 17:54:02]: {"
sessionId":"06b85ea6-84c3-427a-8211-101f1c3ae587","status":0
}
>> macaca-chromedriver.js:168:18 [master] pid:123744 chromedriver exit with code
: null, signal: SIGTERM


@harsayer
已经根据系统的chrome版本,选择了对应的驱动,一到官方demo的第4个切换网页的就挂了,这要如何解决,模拟器跟真机都挂了,换了好几个版本都不行

执行上述的自家apk测试脚本后,会弹出这个报错,有什么解决办法?

Traceback (most recent call last):
File "e:\Test\Python\Script\macaca.py", line 4, in <module>
from macaca import WebDriver
File "e:\Test\Python\Script\macaca.py", line 4, in <module>
from macaca import WebDriver
ImportError: cannot import name WebDriver
jierong01 回复

官网的例子遇到同样问题,如何处理?

@harsayer 请教一个问题,环境是win7。我安装macaca-android驱动的时候报错。这是我SDKManager里为何没有android25.0.2啊?
我这里的报错日志是Checking the license for package Android SDK Build-Tools 25.0.2 in E:\ADT\sdk\licenses
Warning: License for package Android SDK Build-Tools 25.0.2 not accepted.
Checking the license for package Android SDK Platform 26 in E:\ADT\sdk\licenses
Warning: License for package Android SDK Platform 26 not accepted.

BUILD FAILED in 1m 53s
,
FAILURE: Build failed with an exception.

  • What went wrong: A problem occurred configuring project ':app'. > You have not accepted the license agreements of the following SDK components: [Android SDK Build-Tools 25.0.2, Android SDK Platform 26]. Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK M anager. Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
小马 #17 · April 25, 2018 作者
刘刘刘 回复

Warning: License for package Android SDK Build-Tools 25.0.2 not accepted.
Checking the license for package Android SDK Platform 26 in E:\ADT\sdk\licenses
Warning: License for package Android SDK Platform 26 not accepted.

提示你当初安装sdk的时候 没接受licenses许可协议。

这个可以先安装不接受 后续有解决方案 就是:
1 如果是win10环境
android-sdk-windows\tools\bin>sdkmanager --update
去你的 ***\tools\bin 目录执行下 sdkmanager --update 会出来两个许可提示 选y 回车 即可
(sdkmanager --licenses win10 cmd下 会提示不存在该参数 然后列出来许多可支持的参数 我看了下 选择了--update 后 就可以了.)
最后一个 可能会卡一会 等一会儿 在ctrl+c 停止就可以了)

2如果是mac 或 ubuntu环境
android-sdk-linux/tools> sdkmanager --licenses

然后目录下 会多个

再执行macaca doctor 就不会有 红色的提示了
Not accepted Android SDK license agreements

@harsayer 我的macaca -doctor是没问题的
就是在npm macaca-android -g的时候没有生成app-debug.apk,不知道是怎么回事!!!

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