From a8102c95eb83c895b775a1a156e16c68ea4ae8b5 Mon Sep 17 00:00:00 2001 From: "Zhuohuan LI (CARPE DIEM)" Date: Wed, 18 May 2016 23:40:08 +0800 Subject: [PATCH] doc --- README.md | 22 ++++++++++++-------- test/webdriver-spec.js | 46 ++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d7cbe958..ac625cfe 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ Plan to glue with Machine Learning/Deep Learning/Neural Network/Natural Language # Installation & Usage Use NPM is recommended to install Wechaty for you: -```bash -$ npm install --save wechaty +```shell +npm install --save wechaty ``` ## Start from strach @@ -69,6 +69,7 @@ In case that you do not know anything about nodejs, the follow instructions woul ## 1. Install NodeJS NodeJS Version 6.0 & above is required. + 1. Visit [NodeJS](https://nodejs.org) 1. Download NodeJS Installer(i.e. "v6.2.0 Current") 1. Run Installer to install NodeJS to your machine @@ -76,8 +77,7 @@ NodeJS Version 6.0 & above is required. ## 2. Checkout Wechaty Use `git` to checkout Wechaty source code from [Github.com](https://github.com) ```shell -git clone git@github.com:zixia/wechaty.git -# git clone https://github.com/zixia/wechaty.git +git clone https://github.com/zixia/wechaty.git ``` ## 3. Install Dependents @@ -89,8 +89,8 @@ npm install ## 4. Run Demo Bot ```shell npm start -# node example/ding-dong-bot.js ``` +This will run `node example/ding-dong-bot.js` # Trouble Shooting If wechaty is not run as expected, run unit test maybe help to find some useful message. @@ -100,7 +100,7 @@ npm test # Requirement -ECMAScript2015/ES6. I develop and test wechaty under nodejs6.0. +ECMAScript2015(ES6). I develop and test wechaty with Node.js v6.0. # API Refference @@ -278,8 +278,14 @@ Github Issue - https://github.com/zixia/wechaty/issues * Create an issue, fork, then send a pull request(with unit test please). # See Also -* [wxBot](https://github.com/liuwons/wxBot): Wechat Bot API in Python -* [ItChat](https://github.com/littlecodersh/ItChat): 微信个人号接口(支持文件、图片上下载)、微信机器人及命令行微信。三十行即可自定义个人号机器人 in Python + +## Javascript +1. [Weixinbot](https://github.com/feit/Weixinbot) Nodejs 封装网页版微信的接口,可编程控制微信消息 + +## Python +1. [WeixinBot](https://github.com/Urinx/WeixinBot) *Very well documented* 网页版微信API,包含终端版微信及微信机器人 +1. [wxBot](https://github.com/liuwons/wxBot): Wechat Bot API +1. [ItChat](https://github.com/littlecodersh/ItChat): 微信个人号接口(支持文件、图片上下载)、微信机器人及命令行微信。三十行即可自定义个人号机器人 Author ----------------- diff --git a/test/webdriver-spec.js b/test/webdriver-spec.js index 69020664..c87a0f72 100644 --- a/test/webdriver-spec.js +++ b/test/webdriver-spec.js @@ -1,4 +1,5 @@ const path = require('path') +const co = require('co') const test = require('tape') const log = require('npmlog') //log.level = 'silly' @@ -14,31 +15,28 @@ test('WebDriver smoke testing', function(t) { const wb = new PuppetWebBrowser({port: PORT}) const driver = wb.getDriver() - const injectio = PuppetWebBrowser.getInjectio() - - driver.get('https://wx.qq.com/') - .then(() => { - Promise.all([ - execute('return 1+1') // ret_add - , execute(injectio, 8788) // ret_inject - ]).then(([ - retAdd - , retInject - ]) => { - t.equal(retAdd , 2 , 'execute js in browser') - t.equal(retInject, 'Wechaty' , 'injected wechaty') - - t.end() - driver.quit() - }).catch(e => { - t.ok(false, 'promise rejected. e:' + e) - t.end() - driver.quit() - })/* .finally(() => { - console.log('final') - }) - */ + co(function* () { + const injectio = PuppetWebBrowser.getInjectio() + yield driver.get('https://wx.qq.com/') + + const retAdd = yield execute('return 1+1') + t.equal(retAdd, 2, 'execute js in browser') + + const retInject = yield execute(injectio, 8788) + t.equal(retInject, 'Wechaty', 'injected wechaty') + + }) + .catch(e => { // REJECTED + t.ok(false, 'promise rejected. e:' + e) }) + .then(() => { // FINALLY + t.end() + driver.quit() + }) + + return + + ////////////////////////////////// function execute() { return driver.executeScript.apply(driver, arguments) -- GitLab