提交 d8854edb 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)
上级 07011098
......@@ -86,6 +86,8 @@ export class Bridge {
}
public getInjectio(): string {
log.verbose('PuppetWebBridge', 'getInjectio()')
const fs = require('fs')
const path = require('path')
......@@ -350,6 +352,13 @@ export class Bridge {
* Proxy Call to Wechaty in Bridge
*/
public async proxyWechaty(wechatyFunc, ...args): Promise<any> {
log.verbose('PuppetWebBridge', 'proxyWechaty(%s, %s)'
, wechatyFunc
, args
? args.join(', ')
: ''
)
const argsEncoded = new Buffer(
encodeURIComponent(
JSON.stringify(args)
......@@ -414,6 +423,8 @@ export class Bridge {
* call REAL browser excute for other methods
*/
public execute(script, ...args): Promise<any> {
log.verbose('PuppetWebBridge', 'execute()')
if (!this.puppet || !this.puppet.browser) {
return Promise.reject(new Error('execute(): no puppet or no puppet.browser in bridge'))
}
......@@ -436,6 +447,8 @@ export class Bridge {
}
public ding(data): Promise<any> {
log.verbose('PuppetWebBridge', 'ding(%s)', data)
return this.proxyWechaty('ding', data)
.catch(e => {
log.error('PuppetWebBridge', 'ding(%s) exception: %s', data, e.message)
......
......@@ -34,13 +34,13 @@ test.serial('WebDriver process create & quit test', async t => {
await browser.open()
t.pass('should open successful')
let pids = await browser.getBrowserPids()
let pids = await browser.getBrowserPidList()
t.truthy(pids.length > 0, 'should exist browser process after b.open()')
await browser.quit()
t.pass('quited')
pids = await browser.getBrowserPids()
pids = await browser.getBrowserPidList()
t.is(pids.length, 0, 'no driver process after quit')
})
......@@ -54,7 +54,7 @@ test.serial('WebDriver smoke testing', async t => {
let driver // for help function `execute`
const m = (await browser.getBrowserPids()).length
const m = (await browser.getBrowserPidList()).length
t.is(m, 0, 'should has no browser process before get()')
driver = await browser.driver.init()
......@@ -66,7 +66,7 @@ test.serial('WebDriver smoke testing', async t => {
await driver.get('https://wx.qq.com/')
t.pass('should open wx.qq.com')
const n = (await browser.getBrowserPids()).length
const n = (await browser.getBrowserPidList()).length
t.truthy(n > 0, 'should exist browser process after get()')
const retAdd = await driverExecute('return 1+1')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册