该文为 macaca 的 nodejs 版本
macaca java 版本 https://github.com/macacajs/wd.java
macaca python 版本 https://github.com/macacajs/wd.py
http://blog.csdn.net/yuxiayiji/article/details/37812785
照着这个来吧。装 java8 即可。最后 java 的 PATH 我是设置到~/.profile 下的。
#Java Environment Path
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
此处 http://tools.android-studio.org/index.php/sdk 处下载 android-sdk_r24.4.1-linux.tgz
cd /opt 下
sudo tar -zxvf android-sdk_r24.4.1-linux.tgz /opt
解压后的目录改名为 android-sdk-linux
sudo mv android-sdk_r24.4.1-linux android-sdk-linux
(此处最好 ls -al 下查看下解压并改名出来的 android-sdk-linux 的所属用户和用户组和权限,我是看到所属用户和组是数字?好像是忘了没记录。我就 chown -R 用户:用户组 给都给改成我当前账号的了)
设置 PATH 到 ~/.profile 末尾
#Android-sdk-linux Path
export ANDROID_HOME=/opt/android-sdk-linux
export PATH=$PATH::$ANDROID_HOME/tools/:$ANDROID_HOME/platform-tools
然后到/opt/android-sdk-linux/tools$ ./android update sdk
启动 sdk manager 下载配置 sdk
我是下载的https://nodejs.org/en/ 主页的 V4.4.7 LTS 也就是 node-v4.4.7-linux-x64.tar.xz
把他
sudo cp node-v4.4.7-linux-x64.tar.xz /opt
cd /opt 目录下
然后
xz -d node-v4.4.7-linux-x64.tar.xz
再
tar -xvf node-v4.4.7-linux-x64.tar
然后解压后的目录改名为 nodejs
sudo mv node-v4.4.7-linux-x64 nodejs
(此处最好 ls -al 下查看下解压并改名出来的 nodejs 的所属用户和用户组和权限 我是看到所属用户和组是数字?好像是忘了没记录。
我就 chown -R 用户:用户组 nodejs 给都给改成我当前账号的了)
然后添加 PATH 到 sudo gedit ~/.profile 末尾添加 export PATH=$PATH:/opt/nodejs/bin
#Nodejs Environment Path
export PATH=$PATH:/opt/nodejs/bin
可能 node -v 后并不会成功,需要关掉终端再打开新终端来尝试,我好像重启过系统。
如果是添加到/etc/profile 可以执行命令 source /etc/profile 或 添加到~/.profile 下的话 source ~/.profile 来让环境变量 PATH 立即生效。
我最后的~/.profile 文件末尾是这样的
#Java Environment Path
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#Android-sdk-linux Path
export ANDROID_HOME=/opt/android-sdk-linux
export PATH=$PATH::$ANDROID_HOME/tools/:$ANDROID_HOME/platform-tools
#Nodejs Environment Path
export PATH=$PATH:/opt/nodejs/bin
#Jmeter Environment Path
export JMETER_HOME=/home/cmd/apache-jmeter-3.0
export CLASSPATH=.:${JMETER_HOME}/lib/ext/ApacheJMeter_core.jar:${JMETER_HOME}/lib/jorphan.jar:${JMETER_HOME}/lib/logkit-2.0.jar
export PATH=${JMETER_HOME}/bin:$PATH
查看下默认的一些 node 和 npm 配置信息
cmd@TR:~$ node -v
v4.4.7
cmd@TR:~$ npm -v
2.15.8
cmd@TR:~$ npm config get prefix
/opt/nodejs
cmd@TR:~$ npm config get cache
/home/cmd/.npm
cmd@TR:~$ npm config get registry
https://registry.npmjs.org/
先修改下默认安装源
cmd@TR:~$ npm config set registry http://registry.cnpmjs.org
cmd@TR:~$ npm config get registry
http://registry.cnpmjs.org/
再安装 3.8.7 版本的 npm
cmd@TR:~$ npm install npm@3.8.7 -g
/opt/nodejs/bin/npm -> /opt/nodejs/lib/node_modules/npm/bin/npm-cli.js
npm@3.8.7 /opt/nodejs/lib/node_modules/npm
npm install -g appium 这个需要点耐心,取决于和它服务器的连接速度. 如果命令进度输出看不出来是否还在下载组件,您可以到 npm cache 目录也就是/home/cmd/.npm 下,来按时间倒序看是否有新文件在下载. 如果长时间没有新文件下载生成,那你可以 ctrl+c 暂停,再重新执行安装命令来一遍,多试几次就可以成功安装了.
PS:如果是只要 macaca 实际这步安装 appium 可以略过.笔者是安装 macaca 前安装了 appium 了的 .
cmd@TR:~$ npm i macaca-cli -g
日志略
查看安装成功后的一些信息:
cmd@TR:~$ macaca -v
1.1.0
cmd@TR:~$ macaca doctor
Node.js checklist:
node env: /opt/nodejs/bin/node
node version: v4.4.7
Android checklist:
JAVA version is `1.8.0_101`
JAVA_HOME is set to `/usr/lib/jvm/java-8-oracle`
ANDROID_HOME is set to `/opt/android-sdk-linux`
Platforms is set to `/opt/android-sdk-linux/platforms/android-19`
Android tools is set to `/opt/android-sdk-linux/tools/android`
Installed driver list:
android: 1.0.23
chrome: 1.0.1
electron: 1.0.7
正常的第一次安装的话,这小节 Installed driver list: 实际是空的.我这里有是因为之前安装过 macaca 1.0.36 版本 ,在此版本下安装过 macaca-android macaca-chrome macaca-electron 驱动所致.
cmd@TR:~$ npm i macaca-chrome -g
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
/opt/nodejs/lib
└─┬ macaca-chrome@1.0.1
└─┬ macaca-utils@0.1.8
└─┬ xutil@1.0.1
└── rimraf@2.5.4
cmd@TR:~$ npm i macaca-android -g
npm WARN deprecated win-spawn@2.0.0: use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) or [cross-spawn-async](https://github.com/IndigoUnited/node-cross-spawn-async) instead.
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
/opt/nodejs/lib
└─┬ macaca-android@1.0.23
├─┬ macaca-adb@1.0.17
│ ├─┬ npm-update@1.0.2
│ │ └─┬ co-request@0.2.1
│ │ └─┬ request@2.74.0
│ │ └── tough-cookie@2.3.0
│ └─┬ xutil@1.0.1
│ └── rimraf@2.5.4
└─┬ macaca-chromedriver@1.0.15
└─┬ request@2.69.0
└── tough-cookie@2.2.2
cmd@TR:~$ npm i macaca-electron -g
/opt/nodejs/lib
└─┬ macaca-electron@1.0.7
├─┬ electron-prebuilt@0.37.8
│ └─┬ electron-download@2.1.2
│ └─┬ nugget@1.6.2
│ └─┬ request@2.74.0
│ └── tough-cookie@2.3.0
└─┬ macaca-utils@0.1.8
└─┬ xutil@1.0.1
└── rimraf@2.5.4
这里的日志也是第二次覆盖安装的日志,初次安装的日志不是这样.
PS:如果遇到安装问题,请导入
cmd@TR:~/macaca/macaca-test-sample-master$ export CHROMEDRIVER_CDNURL=http://npm.taobao.org/mirrors/chromedriver/
cmd@TR:~/macaca/macaca-test-sample-master$ export ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
不添加下载可能会报错,添加后安装驱动就正常了.
https://github.com/macacajs/macaca-test-sample 下载 macaca-test-sample-master.zip 解压到 D:\macaca\下
2016年8月23日补充:
由于之前对 git 和 maven 部署项目还不是很有感,所以采用了下载.zip 的方式.实际使用 git clone 来 down 项目在后续才是最方便的.
所以此处,当然也可以 git clone https://github.com/macacajs/macaca-test-sample.git 来将 macaca-test-sample down 到你需要的目录下.
如:
cmd@TR:~/macaca$ git clone https://github.com/macacajs/macaca-test-sample.git
正克隆到 'macaca-test-sample'...
remote: Counting objects: 55, done.
remote: Total 55 (delta 0), reused 0 (delta 0), pack-reused 55
展开对象中: 100% (55/55), 完成.
检查连接... 完成。
cmd@TR:~/macaca$ ls -al
总用量 80
drwxr-xr-x 5 cmd cmd 4096 8月 23 12:57 .
drwxr-xr-x 62 cmd cmd 4096 8月 23 11:39 ..
-rw-rw-r-- 1 cmd cmd 59889 7月 25 09:17 macacaLog
drwxrwxr-x 5 cmd cmd 4096 8月 23 12:58 macaca-test-sample
补充结束.
macaca/macaca-test-sample-master/macaca-test 下找到文件 macaca-desktop-sample.test.js
打开编辑
找到内容
var wd = require('webdriver-client')({
platformName: 'desktop',
browserName: 'electron'
将 browserName: 'electron' 修改为 browserName: 'chrome'
PS: 有的人说 chrome 有问题,那你肯定要先安装好 chrome 浏览器在本机啊.下边是安装 chrome 浏览器的方式,你可以官网找到.deb 包来安装,
也可以通过添加官方 PPA 源的方式来安装.
http://ubuntuportal.com/2014/04/how-to-install-google-chrome-web-browser-in-ubuntu-14-04-lts-trusty-tahr.html
笔者我跑样例时的 chrome 浏览器的版本是版本 50.0.2661.94 (64-bit)
到样例项目有文件 package.json 的目录下 ,执行 npm i 为样例项目安装 macaca 执行环境依赖
cmd@TR:~$ cd macaca/macaca-test-sample-master/
cmd@TR:~/macaca/macaca-test-sample-master$ npm i
2016年7月25日执行成功日志
cmd@TR:~/macaca/macaca-test-sample-master$ make test
make test-ios Test sample for iOS
make test-ios-safari Test sample for iOS Safari
make test-android Test sample for Android
make test-android-chrome Test sample for Android Chrome
make test-pc Test sample for PC
cmd@TR:~/macaca/macaca-test-sample-master$ make test-pc
npm install macaca-electron --save-dev
> electron-prebuilt@0.37.8 postinstall /home/cmd/macaca/macaca-test-sample-master/node_modules/electron-prebuilt
> node install.js
Downloading electron-v0.37.8-linux-x64.zip
[============================================>] 100.0% of 39.94 MB (4.32 MB/s)
macaca-test-sample@1.0.8 /home/cmd/macaca/macaca-test-sample-master
└─┬ macaca-electron@1.0.7
├── driver-base@0.1.1
├─┬ electron-prebuilt@0.37.8
│ ├─┬ electron-download@2.1.2
│ │ ├── home-path@1.0.3
│ │ ├── minimist@1.2.0
│ │ ├─┬ mv@2.1.1
│ │ │ ├── ncp@2.0.0
│ │ │ └─┬ rimraf@2.4.5
│ │ │ └── glob@6.0.4
│ │ ├─┬ nugget@1.6.2
│ │ │ ├── minimist@1.2.0
│ │ │ ├─┬ pretty-bytes@1.0.4
│ │ │ │ ├── get-stdin@4.0.1
│ │ │ │ └─┬ meow@3.7.0
│ │ │ │ ├─┬ camelcase-keys@2.1.0
│ │ │ │ │ └── camelcase@2.1.1
│ │ │ │ ├── decamelize@1.2.0
│ │ │ │ ├─┬ loud-rejection@1.6.0
│ │ │ │ │ ├─┬ currently-unhandled@0.4.1
│ │ │ │ │ │ └── array-find-index@1.0.1
│ │ │ │ │ └── signal-exit@3.0.0
│ │ │ │ ├── map-obj@1.0.1
│ │ │ │ ├── minimist@1.2.0
│ │ │ │ ├─┬ normalize-package-data@2.3.5
│ │ │ │ │ ├── hosted-git-info@2.1.5
│ │ │ │ │ ├─┬ is-builtin-module@1.0.0
│ │ │ │ │ │ └── builtin-modules@1.1.1
│ │ │ │ │ ├── semver@5.3.0
│ │ │ │ │ └─┬ validate-npm-package-license@3.0.1
│ │ │ │ │ ├─┬ spdx-correct@1.0.2
│ │ │ │ │ │ └── spdx-license-ids@1.2.1
│ │ │ │ │ └─┬ spdx-expression-parse@1.0.2
│ │ │ │ │ └── spdx-exceptions@1.0.5
│ │ │ │ ├── object-assign@4.1.0
│ │ │ │ ├─┬ read-pkg-up@1.0.1
│ │ │ │ │ ├─┬ find-up@1.1.2
│ │ │ │ │ │ └── path-exists@2.1.0
│ │ │ │ │ └─┬ read-pkg@1.1.0
│ │ │ │ │ ├─┬ load-json-file@1.1.0
│ │ │ │ │ │ ├── graceful-fs@4.1.4
│ │ │ │ │ │ ├─┬ parse-json@2.2.0
│ │ │ │ │ │ │ └─┬ error-ex@1.3.0
│ │ │ │ │ │ │ └── is-arrayish@0.2.1
│ │ │ │ │ │ ├── pify@2.3.0
│ │ │ │ │ │ └─┬ strip-bom@2.0.0
│ │ │ │ │ │ └── is-utf8@0.2.1
│ │ │ │ │ └─┬ path-type@1.1.0
│ │ │ │ │ └── graceful-fs@4.1.4
│ │ │ │ ├─┬ redent@1.0.0
│ │ │ │ │ ├─┬ indent-string@2.1.0
│ │ │ │ │ │ └─┬ repeating@2.0.1
│ │ │ │ │ │ └─┬ is-finite@1.0.1
│ │ │ │ │ │ └── number-is-nan@1.0.0
│ │ │ │ │ └── strip-indent@1.0.1
│ │ │ │ └── trim-newlines@1.0.0
│ │ │ ├─┬ progress-stream@1.2.0
│ │ │ │ ├── speedometer@0.1.4
│ │ │ │ └─┬ through2@0.2.3
│ │ │ │ └─┬ xtend@2.1.2
│ │ │ │ └── object-keys@0.4.0
│ │ │ ├── single-line-log@0.4.1
│ │ │ └── throttleit@0.0.2
│ │ ├── path-exists@1.0.0
│ │ └─┬ rc@1.1.6
│ │ ├── deep-extend@0.4.1
│ │ ├── ini@1.3.4
│ │ └── minimist@1.2.0
│ └─┬ extract-zip@1.5.0
│ ├─┬ concat-stream@1.5.0
│ │ └─┬ readable-stream@2.0.6
│ │ └── isarray@1.0.0
│ ├── debug@0.7.4
│ ├── mkdirp@0.5.0
│ └─┬ yauzl@2.4.1
│ └─┬ fd-slicer@1.0.1
│ └── pend@1.2.0
└── selenium-atoms@1.0.1
macaca doctor
Node.js checklist:
node env: /opt/nodejs/bin/node
node version: v4.4.7
Android checklist:
JAVA version is `1.8.0_101`
JAVA_HOME is set to `/usr/lib/jvm/java-8-oracle`
ANDROID_HOME is set to `/opt/android-sdk-linux`
Platforms is set to `/opt/android-sdk-linux/platforms/android-19`
Android tools is set to `/opt/android-sdk-linux/tools/android`
Installed driver list:
android: 1.0.23
chrome: 1.0.1
electron: 1.0.7
macaca run --verbose -d ./macaca-test/macaca-desktop-sample.test.js
>> index.js:17:12 [master] pid:23160 webdriver server start with config:
{ port: 3456,
window: true,
ip: '192.168.66.113',
host: 'TR',
loaded_time: '2016-07-25 08:49:28' }
>> middlewares.js:17:10 [master] pid:23160 base middlewares attached
>> router.js:108:10 [master] pid:23160 router set
>> webdriver sdk launched
>>
>>
>> macaca desktop sample
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"autoAcceptAlerts":true,"browserName":"chrome","platformName":"desktop","version":"","javascriptEnabled":true,"platform":"ANY"}}
>> session.js:47:10 [master] pid:23160 Creating session, sessionId: d8b73e8c-98d5-46c7-8a44-1f42ae62927d.
>> chromedriver bin path: /opt/nodejs/lib/node_modules/macaca-chrome/node_modules/macaca-chromedriver/exec/chromedriver
>> Kill all running chromedriver process by: ps -ef | grep chromedriver | grep -v grep | grep -e '--port=9515' | awk '{ print $2 }' | xargs -r kill -15
>> kill all chromedriver process success!
>> Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 9515
Only local connections are allowed.
>> chromedriver starting success.
>> proxy.js:52:14 [master] pid:23160 Proxy: /status:GET to http://localhost:9515/wd/hub/status:GET with body:
Error: chromedriver proxy error with: Error: connect ECONNREFUSED 127.0.0.1:9515
at Request._callback (/opt/nodejs/lib/node_modules/macaca-chrome/node_modules/macaca-chromedriver/lib/proxy.js:56:25)
at self.callback (/opt/nodejs/lib/node_modules/macaca-chrome/node_modules/request/request.js:199:22)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at Request.onRequestError (/opt/nodejs/lib/node_modules/macaca-chrome/node_modules/request/request.js:821:8)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:267:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
>> proxy.js:52:14 [master] pid:23160 Proxy: /status:GET to http://localhost:9515/wd/hub/status:GET with body:
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Linux\",\"version\":\"4.4.0-31-generic\"}}}"
>> proxy.js:52:14 [master] pid:23160 Proxy: /session:POST to http://localhost:9515/wd/hub/session:POST with body: {"desiredCapabilities":{"autoAcceptAlerts":true,"browserName":"chrome","platformName":"desktop","version":"","javascriptEnabled":true,"platform":"ANY","window":true}}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"userData...
>> chromedriver ready with: {"sessionId":null,"status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"userDataDir":"/tmp/.com.google.Chrome.a6cIAK"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"platform":"Linux","rotatable":false,"takesHeapSnapshot":true,"takesScreenshot":true,"version":"50.0.2661.94","webStorageEnabled":true}}
>> responseHandler.js:43:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"autoAcceptAlerts\":true,\"browserName\":\"chrome\",\"platformName\":\"desktop\",\"version\":\"\",\"javascriptEnabled\":true,\"platform\":\"ANY\",\"window\":true}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/window/current/size, jsonBody: {"width":1280,"height":800}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/window/current/size:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/window/current/size:POST with body: {"width":1280,"height":800}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/url, jsonBody: {"url":"https://www.baidu.com"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/url:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/url:POST with body: {"url":"https://www.baidu.com"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>>
>> ✓ #0 should go into macaca (4614ms)
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element, jsonBody: {"using":"id","value":"kw"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element:POST with body: {"using":"id","value":"kw"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"ELEMENT":"0.2751949436867389-1"}}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"ELEMENT\":\"0.2751949436867389-1\"}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-1/value, jsonBody: {"value":["macaca"]}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-1/value:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.2751949436867389-1/value:POST with body: {"value":["macaca"]}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"ELEMENT":"0.2751949436867389-2"}}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"ELEMENT\":\"0.2751949436867389-2\"}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-2/click:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.2751949436867389-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/source, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/source:GET to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/source:GET with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":"<!DOCTYPE html><!--STATUS OK--><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"content-type\" content=\"tex...
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"\"<!DOCTYPE html><!--STATUS OK--><html xmlns=\\\"http://www.w3.org/1999/xhtml\\\"><head><meta http-equiv=\\\"content-type\\\" content=\\\"text/html;charset=utf-8\\\" /><style data-for=\\\"result\\\" id=\\\"css_result\\\">body{color:#333;background:#fff;padding:6px 0 0;margin:0;position:relative;min-width:900px}body,th,td,.p1,.p2{font-family:arial}p,form,ol,ul,li,dl,dt,dd,h3{margin:0;padding:0;list-style:none}input{..."}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/elements, jsonBody: {"using":"css selector","value":"#head > div.head_wrapper"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/elements:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/elements:POST with body: {"using":"css selector","value":"#head > div.head_wrapper"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":[{"ELEMENT":"0.2751949436867389-3"}]}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"[{\"ELEMENT\":\"0.2751949436867389-3\"}]"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/elements, jsonBody: {"using":"xpath","value":"//*[@id=\"kw\"]"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/elements:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/elements:POST with body: {"using":"xpath","value":"//*[@id=\"kw\"]"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":[{"ELEMENT":"0.2751949436867389-1"}]}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"[{\"ELEMENT\":\"0.2751949436867389-1\"}]"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-1/value, jsonBody: {"value":[" elementByXPath"]}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-1/value:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.2751949436867389-1/value:POST with body: {"value":[" elementByXPath"]}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"ELEMENT":"0.2751949436867389-2"}}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"ELEMENT\":\"0.2751949436867389-2\"}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.2751949436867389-2/click:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.2751949436867389-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/screenshot, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/screenshot:GET to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/screenshot:GET with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdfUBT9foA8GcvZ3AmmzCUWWAuhQwUVFBQIcWCvHjDDFQyLDHRpJukkFC+YkmCV7GwxK5U+...
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"\"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdfUBT9foA8GcvZ3AmmzCUWWAuhQwUVFBQIcWCvHjDDFQyLDHRpJukkFC+YkmCV7GwxK5U+EKKPyHFW1yFChVMUBDBJAVrJqhDmLjBBjtn2++Pg2OMF9FAiZ7PXztn33P23Rkve87z/T5fll6vB4QQQgghhBBCqE9SKBTdb8zuvX4ghBBCCCGEEEKPEoa4CCGEEEIIIYT6CQxxEUIIIYQQQgj1ExjiIoQQQgghhBDqJzDERQghhBBCCCHUT2CIixBCCCGEEELoLyYzM7PD/X09xK2+eCPojVtObn/MCLiRd1pN061LHOn1eo1Gd7Oi7rfCPxqUtE6re4z9RAgh..."}
>>
>> ✓ #1 should works with macaca (16834ms)
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/url, jsonBody: {"url":"https://www.baidu.com"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/url:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/url:POST with body: {"url":"https://www.baidu.com"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>>
>> ✓ #2 should go into web (3357ms)
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element, jsonBody: {"using":"id","value":"kw"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element:POST with body: {"using":"id","value":"kw"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"ELEMENT":"0.35874682741011266-1"}}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"ELEMENT\":\"0.35874682741011266-1\"}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.35874682741011266-1/value, jsonBody: {"value":["TesterHome"]}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.35874682741011266-1/value:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.35874682741011266-1/value:POST with body: {"value":["TesterHome"]}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":{"ELEMENT":"0.35874682741011266-2"}}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"{\"ELEMENT\":\"0.35874682741011266-2\"}"}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.35874682741011266-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/element/0.35874682741011266-2/click:POST to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/element/0.35874682741011266-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":null}
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/source, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/source:GET to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/source:GET with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":"<!DOCTYPE html><!--STATUS OK--><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"content-type\" content=\"tex...
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"\"<!DOCTYPE html><!--STATUS OK--><html xmlns=\\\"http://www.w3.org/1999/xhtml\\\"><head><meta http-equiv=\\\"content-type\\\" content=\\\"text/html;charset=utf-8\\\" /><style data-for=\\\"result\\\" id=\\\"css_result\\\">body{color:#333;background:#fff;padding:6px 0 0;margin:0;position:relative;min-width:900px}body,th,td,.p1,.p2{font-family:arial}p,form,ol,ul,li,dl,dt,dd,h3{margin:0;padding:0;list-style:none}input{..."}
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/screenshot, jsonBody: {}
>> proxy.js:52:14 [master] pid:23160 Proxy: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d/screenshot:GET to http://localhost:9515/wd/hub/session/1f04370c5675c5da502e054c6ac38413/screenshot:GET with body: {}
>> proxy.js:58:16 [master] pid:23160 Got response with status 200: {"sessionId":"1f04370c5675c5da502e054c6ac38413","status":0,"value":"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BT5foA8Gc/zsaZbOJQpoLJTdBAQQSFFEpMsTAxg5K8WFFqSd8kwwJLUyxJsKTCbtSVb...
>> session.js:107:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0,"value":"\"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BT5foA8Gc/zsaZbOJQpoLJTdBAQQSFFEpMsTAxg5K8WFFqSd8kwwJLUyxJsKTCbtSVbmiS4b2QgleugoUKKihEYBCCNRPUIZuwwQ7bOdu+fwzGGKBgoETP56/tPe85ezgbsOc873lflsFgAIQQQgghhBBCaEhSKpV978wevDgQQgghhBBCCKG7CVNchBBCCCGEEELDBKa4CCGEEEIIIYSGCUxxEUIIIYQQQggNE5jiIoQQQgghhBAaJjDFRQghhBBCCCH0J5OVldVj+1BPcesvXA197rqr1++Lgq8WnKYYpnOJI4PBoNXqr9XIfy3+vUXF6HX6exgnQggh..."}
>>
>> ✓ #3 should works with web (8545ms)
>> responseHandler.js:11:12 [master] pid:23160 Recieve HTTP Request from Client: method: DELETE url: /wd/hub/session/d8b73e8c-98d5-46c7-8a44-1f42ae62927d, jsonBody: {}
>> Kill all running chromedriver process by: ps -ef | grep chromedriver | grep -v grep | grep -e '--port=9515' | awk '{ print $2 }' | xargs -r kill -15
>> macaca-chromedriver.js:141:18 [master] pid:23160 chromedriver exit with code: null, signal: SIGTERM
>> session.js:80:12 [master] pid:23160 Delete session, sessionId: d8b73e8c-98d5-46c7-8a44-1f42ae62927d
>> responseHandler.js:43:14 [master] pid:23160 Send HTTP Respone to Client: {"sessionId":"d8b73e8c-98d5-46c7-8a44-1f42ae62927d","status":0}
>>
>>
>> 4 passing (36s)
>>
>> Test completed!
日志还是有一些信息可以看出 macaca 执行脚本时候的逻辑或者组件包依赖逻辑的.
该节日志的最后一小节为之前 1.0.36 的一个 BUG 问题记录.该 bug 是这样的,一执行 make test-pc 后你会发现 macaca 被卸载掉了好像,
提示找不到命令 macaca.该 bug 在 1.1.0 版本已修复。