Macaca ubuntu16.04 尝试 nodejs 版 macaca reportor 报告器

老马 · 2016年09月22日 · 最后由 达峰的夏天 回复于 2017年08月25日 · 2652 次阅读

今天看到发布了 nodejs 版 macaca reportor 报告器 如何自定义 Macaca 报告器
接下来就来尝试下.

一 先 git clone macaca-test-sample

cmd@TR:~/macaca$ git clone https://github.com/macacajs/macaca-test-sample.git

执行 npm i 为样例项目安装 macaca 执行环境依赖 (关于 macaca nodejs 的执行环境部署问题请参考ubuntu16.04 环境折腾 macaca 总结记
cmd@TR:~/macaca/macaca-test-sample-master$ npm i

browserName: 'electron' 脚本里 的这句改为 browserName: 'chrome' 当然你也可以用 electron 的 只要 npm i macaca-electron -g 正确安装了 electron 驱动也可以的。
.

二 进入该目录下安装 macaca-simple-reportor

cmd@TR:~/macaca/macaca-test-sample$ npm i macaca-simple-reportor --save-dev
macaca-test-sample@1.0.11 /home/cmd/macaca/macaca-test-sample
└─┬ macaca-simple-reportor@1.0.0 
  └── macaca-utils@0.1.9 

三 执行带报告配置的执行脚本命令

cmd@TR:~/macaca/macaca-test-sample$ CUSTOM_DIR=macaca-logs/macaca-desktop-sample macaca run --verbose -d ./macaca-test/macaca-desktop-sample.test.js --reporter macaca-simple-reportor
>> request.js:23:12 [master] pid:20138 get remote update info failed.
>> index.js:17:12 [master] pid:20156 webdriver server start with config:
 { port: 3456,
  window: true,
  ip: '192.168.66.113',
  host: 'TR',
  loaded_time: '2016-09-22 10:30:12' }
>> middlewares.js:17:10 [master] pid:20156 base middlewares attached
>> router.js:108:10 [master] pid:20156 router set
>> webdriver sdk launched
>> 

>> 

>>   macaca desktop sample

>> responseHandler.js:11:12 [master] pid:20156 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:20156 Creating session, sessionId: 01196cb7-a8ad-4a82-a17a-9ee0f616ecee.
>> 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:20156 Proxy: /status:GET to http://localhost:9515/wd/hub/status:GET with body: 
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Linux\",\"version\":\"4.4.0-38-generic\"}}}"
>> proxy.js:52:14 [master] pid:20156 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","show":true}}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","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.xFj9lv"},"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:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"autoAcceptAlerts\":true,\"browserName\":\"chrome\",\"platformName\":\"desktop\",\"version\":\"\",\"javascriptEnabled\":true,\"platform\":\"ANY\",\"show\":true}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/window/current/size, jsonBody: {"width":1280,"height":800}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/window/current/size:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/window/current/size:POST with body: {"width":1280,"height":800}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/url, jsonBody: {"url":"https://www.baidu.com"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/url:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/url:POST with body: {"url":"https://www.baidu.com"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>>     ✓ #0 should go into macaca (4522ms)

>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element, jsonBody: {"using":"id","value":"kw"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element:POST with body: {"using":"id","value":"kw"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":{"ELEMENT":"0.011266911329333329-1"}}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"ELEMENT\":\"0.011266911329333329-1\"}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-1/value, jsonBody: {"value":["macaca"]}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-1/value:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.011266911329333329-1/value:POST with body: {"value":["macaca"]}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":{"ELEMENT":"0.011266911329333329-2"}}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"ELEMENT\":\"0.011266911329333329-2\"}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-2/click:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.011266911329333329-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/source, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/source:GET to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/source:GET with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","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:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","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:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/elements, jsonBody: {"using":"css selector","value":"#head > div.head_wrapper"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/elements:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/elements:POST with body: {"using":"css selector","value":"#head > div.head_wrapper"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":[{"ELEMENT":"0.011266911329333329-3"}]}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"[{\"ELEMENT\":\"0.011266911329333329-3\"}]"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/elements, jsonBody: {"using":"xpath","value":"//*[@id=\"kw\"]"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/elements:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/elements:POST with body: {"using":"xpath","value":"//*[@id=\"kw\"]"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":[{"ELEMENT":"0.011266911329333329-1"}]}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"[{\"ELEMENT\":\"0.011266911329333329-1\"}]"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-1/value, jsonBody: {"value":[" elementByXPath"]}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-1/value:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.011266911329333329-1/value:POST with body: {"value":[" elementByXPath"]}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":{"ELEMENT":"0.011266911329333329-2"}}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"ELEMENT\":\"0.011266911329333329-2\"}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.011266911329333329-2/click:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.011266911329333329-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/screenshot, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/screenshot:GET to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/screenshot:GET with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BTVfsA8GdjF7iTDRjKLDCXQgYKIiiYoE6FDL9hBioZluSPkkpSSDDxB5Yk+CoWltgrF...
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"\"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BTVfsA8GdjF7iTDRjKLDCXQgYKIiiYoE6FDL9hBioZluSPkkpSSDDxB5Yk+CoWltgrFSqk+AoZVrwKFSqogCDij6VgzQR1CBM32IC7H98/LowxfogGykvP56/t7Ny7ZxfQPfec8xyGVqsFhBBCCCGEEEKoX5LJZD3vzOy7OBBCCCGEEEIIoccJU1yEEEIIIYQQQgMEprgIIYQQQgghhAYITHERQgghhBBCCA0QmOIihBBCCCGEEBogMMVFCCGEEEIIIfQ/JjMzs9P2/p7iVl26FfjmHUe3v2b538o7rVSp2rY40mq1zc2a2+W1fxT+VS9XadSaJxgnQggh..."}
>>     ✓ #1 should works with macaca (16917ms)

>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/url, jsonBody: {"url":"https://www.baidu.com"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/url:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/url:POST with body: {"url":"https://www.baidu.com"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>>     ✓ #2 should go into web (3385ms)

>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element, jsonBody: {"using":"id","value":"kw"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element:POST with body: {"using":"id","value":"kw"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":{"ELEMENT":"0.4972002364151311-1"}}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"ELEMENT\":\"0.4972002364151311-1\"}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.4972002364151311-1/value, jsonBody: {"value":["TesterHome"]}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.4972002364151311-1/value:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.4972002364151311-1/value:POST with body: {"value":["TesterHome"]}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element, jsonBody: {"using":"id","value":"su"}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element:POST with body: {"using":"id","value":"su"}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":{"ELEMENT":"0.4972002364151311-2"}}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"{\"ELEMENT\":\"0.4972002364151311-2\"}"}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.4972002364151311-2/click, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/element/0.4972002364151311-2/click:POST to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/element/0.4972002364151311-2/click:POST with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":null}
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":null}
>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/source, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/source:GET to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/source:GET with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","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:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","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:20156 Recieve HTTP Request from Client: method: GET url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/screenshot, jsonBody: {}
>> proxy.js:52:14 [master] pid:20156 Proxy: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee/screenshot:GET to http://localhost:9515/wd/hub/session/c197a1bcccd28421abff7ee823a6ef37/screenshot:GET with body: {}
>> proxy.js:58:16 [master] pid:20156 Got response with status 200: {"sessionId":"c197a1bcccd28421abff7ee823a6ef37","status":0,"value":"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BT5foA8GdsZ+NMNnEgU8HcTdBAQQSFFExM0TAxg5K8WFFqSTfJsMDSFEsSLKmwG3Wlb...
>> session.js:107:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0,"value":"\"iVBORw0KGgoAAAANSUhEUgAABPYAAALOCAIAAAClHwr0AAAgAElEQVR4nOzdf0BT5foA8GdsZ+NMNnEgU8HcTdBAQQSFFExM0TAxg5K8WFFqSTfJsMDSFEsSLKmwG3Wlb2iS4b2QgleugYUKKihEoBCCNRPUIZuwwQ7bOdu+fwzG+KVgoETP56+d97znnGdnQ/ec9xfLYDAAQgghhBBCCCE0JCmVyr5Xthi8OBBCCCGEEEIIoXsJU1yEEEIIIYQQQsMEprgIIYQQQgghhIYJTHERQgghhBBCCA0TmOIihBBCCCGEEBomMMVFCCGEEEIIIfQnk5mZ2WP5UE9x6y5cC3nuhovn74uDruWfphimY4kjg8Gg1eqvV8t/Lfq9WcXodfr7GCdCCCGE..."}
>>     ✓ #3 should works with web (8605ms)

>> responseHandler.js:11:12 [master] pid:20156 Recieve HTTP Request from Client: method: DELETE url: /wd/hub/session/01196cb7-a8ad-4a82-a17a-9ee0f616ecee, 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:20156 chromedriver exit with code: null, signal: SIGTERM
>> session.js:80:12 [master] pid:20156 Delete session, sessionId: 01196cb7-a8ad-4a82-a17a-9ee0f616ecee
>> responseHandler.js:43:14 [master] pid:20156 Send HTTP Respone to Client: {"sessionId":"01196cb7-a8ad-4a82-a17a-9ee0f616ecee","status":0}
>> 

>> 

>>   4 passing (34s)

>> 

>> Test completed!

四 去相关目录下看下报告结果

五 发现问题

发现首次执行目录 screenshot 下并没有 pic1 pic2 图片生成.
想了想,应该是其实我这次并没有重新 git clone macaca-test-sample 导致本地很早 clone 的和这次的 reportor 版本的 macaca-test-sample
不一致.
于是看了下https://github.com/macacajs/macaca-test-sample/blob/master/macaca-test/macaca-desktop-sample.test.js
发现自己本地的少了.saveScreenshot('pic1'); 那就先手动修改本地的再执行.
执行后发现还是没有,但是在/macaca/macaca-test-sample/ 项目根目录下到是有了.于是想这个图片报告路径是怎么指定和配置的呢?

于是继续仔细看https://github.com/macacajs/macaca-test-sample
发现

那么来看下 Makefile 和 package.json 吧

大家自行看吧 https://github.com/macacajs/macaca-test-sample/commit/b5654803ff7d41883966b65c56cabde4c11abe93
就会看到此次为了 reportor 是怎么配置修改的.明白了 就以后可以方便为自己的项目更改配置了.

六 win10 环境

基本类似只是到了这里

D:\macaca\macaca-test-sample-master>CUSTOM_DIR=macaca-logs/macaca-desktop-sample macaca run --verbose -d ./macaca-test/macaca-desktop-sample.test.js --reporter macaca-simple-reportor
'CUSTOM_DIR' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

机智如我,稍微改一下如下就可以执行了

D:\macaca\macaca-test-sample-master>macaca run --verbose -d ./macaca-test/macaca-desktop-sample.test.js --reporter macaca-simple-reportor CUSTOM_DIR=macaca-logs/macaca-desktop-sample

遇到个问题:
就是图片并没有在指定的 D:\macaca\macaca-test-sample-master\macaca-logs\macaca-desktop-sample\screenshot 而是出现在了 D:\macaca\macaca-test-sample-master

更多信息请参考 wiki 汇总

小马的 macaca 入门指引合集

更好的 nodejs 版本的测试报告配置请参考

Macaca 如何生成漂亮的测试报告?

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 2 条回复 时间 点赞
老马 [该话题已被删除] 中提及了此贴 09月22日 15:15

最后提供的如何生成更好的测试报告,给了很大的帮助,感谢~

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