Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
23947e6a
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
23947e6a
编写于
9月 01, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
issue
#21
switch back to phantomjs, and headless & head will all be tested
上级
e82be8c8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
24 deletion
+33
-24
package.json
package.json
+7
-5
src/config.js
src/config.js
+5
-4
src/puppet-web/puppet-web.js
src/puppet-web/puppet-web.js
+1
-1
test/puppet-web/puppet-web.spec.js
test/puppet-web/puppet-web.spec.js
+5
-0
test/webdriver-phantomjs.spec.js
test/webdriver-phantomjs.spec.js
+15
-14
未找到文件。
package.json
浏览文件 @
23947e6a
{
"name"
:
"wechaty"
,
"version"
:
"0.3.1
5
"
,
"version"
:
"0.3.1
6
"
,
"description"
:
"Wechat for Bot (Personal Account)"
,
"main"
:
"index.js"
,
"wechaty"
:
{
"DEFAULT_HEAD"
:
"
chrome
"
,
"DEFAULT_HEAD"
:
"
phantomjs
"
,
"DEFAULT_PUPPET"
:
"web"
,
"DEFAULT_PROFILE"
:
"default-profile-name"
,
"DEFAULT_PORT"
:
18788
,
...
...
@@ -16,11 +16,13 @@
"eslint"
:
"eslint
\"
{src,test}/**/*.js
\"
"
,
"tslint"
:
"tslint
\"
{src,test}/**/*.ts
\"
"
,
"pretest"
:
"npm run lint"
,
"test"
:
"npm run test:phantomjs && npm run test:chrome"
,
"test:phantomjs"
:
"cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=phantomjs ava --timeout=10m
\"
{src,test}/**/*.spec.js
\"
"
,
"test:chrome"
:
"cross-env LC_ALL=C WECHATY_LOG=info WECHATY_HEAD=chrome ava --timeout=10m
\"
{src,test}/**/*.spec.js
\"
"
,
"testdev"
:
"cross-env LC_ALL=C WECHATY_LOG=silly ava --serial --verbose --fail-fast --timeout=3m"
"ava"
:
"cross-env LC_ALL=C WECHATY_LOG=verbose ava
\"
{src,test}/**/*.spec.js
\"
"
,
"start"
:
"node bin/io-bot"
,
"demo"
:
"node example/ding-dong-bot.js"
,
"test"
:
"cross-env LC_ALL=C WECHATY_LOG=info ava --timeout=10m
\"
{src,test}/**/*.spec.js
\"
"
,
"ava"
:
"cross-env LC_ALL=C WECHATY_LOG=verbose ava
\"
{src,test}/**/*.spec.js
\"
"
,
"testdev"
:
"cross-env LC_ALL=C WECHATY_LOG=silly ava --serial --verbose --fail-fast --timeout=3m"
},
"repository"
:
{
"type"
:
"git"
,
...
...
src/config.js
浏览文件 @
23947e6a
const
Config
=
{
isDocker
:
!!
process
.
env
.
WECHATY_DOCKER
}
const
Config
=
require
(
'
../package.json
'
).
wechaty
Object
.
assign
(
Config
,
require
(
'
../package.json
'
).
wechaty
)
Object
.
assign
(
Config
,
{
isDocker
:
!!
process
.
env
.
WECHATY_DOCKER
,
head
:
process
.
env
.
WECHATY_HEAD
||
Config
.
DEFAULT_HEAD
})
module
.
exports
=
Config
.
default
=
Config
.
Config
=
Config
src/puppet-web/puppet-web.js
浏览文件 @
23947e6a
...
...
@@ -38,7 +38,7 @@ const Config = require('../config')
class
PuppetWeb
extends
Puppet
{
constructor
({
head
=
Config
.
DEFAULT_HEAD
head
=
Config
.
head
,
profile
=
null
// if not set profile, then do not store session.
}
=
{})
{
super
()
...
...
test/puppet-web/puppet-web.spec.js
浏览文件 @
23947e6a
...
...
@@ -23,6 +23,11 @@ test('Puppet Web Self Message Identification', t => {
t
.
truthy
(
p
.
self
(
m
),
'
should identified self for message which from is self
'
)
})
/**
* the reason why use `test.serial` here is:
* static variable `Contact.puppet` will be changed
* when `PuppteWeb.init()` and `PuppteWeb.quit()`
*/
test
.
serial
(
'
PuppetWeb login/logout events
'
,
async
t
=>
{
let
pw
=
new
PuppetWeb
()
t
.
truthy
(
pw
,
'
should instantiated a PuppetWeb
'
)
...
...
test/webdriver-phantomjs.spec.js
浏览文件 @
23947e6a
...
...
@@ -3,38 +3,38 @@ import express from 'express'
import
*
as
http
from
'
http
'
import
*
as
url
from
'
url
'
import
Phantomjs
from
'
phantomjs-prebuilt
'
import
{
test
}
from
'
ava
'
import
{
UtilLib
,
log
}
from
'
../
'
test
(
'
Phantomjs smoking test
'
,
t
=>
{
const
phantomjsExe
=
require
(
'
phantomjs-prebuilt
'
).
path
test
.
todo
(
'
Phantomjs replace javascript source file content test
'
,
async
t
=>
{
const
phantomjsArgs
=
[
'
--load-images=false
'
,
'
--ignore-ssl-errors=true
'
// this help socket.io connect with localhost
,
'
--web-security=false
'
// https://github.com/ariya/phantomjs/issues/12440#issuecomment-52155299
,
'
--ssl-protocol=TLSv1
'
// https://github.com/ariya/phantomjs/issues/11239#issuecomment-42362211
,
'
--webdriver-loglevel=WARN
'
// , '--webdriver-loglevel=DEBUG'
// , '--webdriver-logfile=webdriver.debug.log'
// , '--remote-debugger-port=8080'
]
phantomjsArgs
.
push
(
'
--remote-debugger-port=8080
'
)
// XXX: be careful when in production env.
phantomjsArgs
.
push
(
'
--webdriver-loglevel=DEBUG
'
)
// phantomjsArgs.push('--webdriver-logfile=webdriver.debug.log')
const
customPhantom
=
WebDriver
.
Capabilities
.
phantomjs
()
.
setAlertBehavior
(
'
ignore
'
)
.
set
(
'
phantomjs.binary.path
'
,
phantomjsExe
)
.
set
(
'
phantomjs.cli.args
'
,
phantomjsArgs
)
.
set
(
'
phantomjs.page.settings.userAgent
'
,
'
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:25.0) Gecko/20100101 Firefox/25.0
'
)
// .setAlertBehavior('ignore')
.
set
(
'
phantomjs.binary.path
'
,
Phantomjs
.
path
)
.
set
(
'
phantomjs.cli.args
'
,
phantomjsArgs
)
const
driver
=
new
WebDriver
.
Builder
()
.
withCapabilities
(
customPhantom
)
.
build
()
.
withCapabilities
(
customPhantom
)
.
build
()
// http://stackoverflow.com/questions/24834403/phantomjs-change-webpage-content-before-evaluating
driver
.
executePhantomJS
(
`
this.onResourceRequested = function(request, net) {
console.log('REQUEST ' + request.url);
alert('REQUEST ' + request.url);
// blockRe = /wx\.qq\.com\/\?t=v2\/fake/i
// https://res.wx.qq.com/zh_CN/htmledition/v2/js/webwxApp2fd632.js
var webwxAppRe = /res\.wx\.qq\.com\/zh_CN\/htmledition\/v2\/js\/webwxApp.+\.js$/i
...
...
@@ -70,7 +70,8 @@ this.onResourceRequested = function(request, net) {
}
}
`
)
driver
.
get
(
'
https://wx.qq.com
'
)
await
driver
.
get
(
'
https://wx.qq.com
'
)
// console.log(await driver.getTitle())
// t.end()
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录