auto-chrome
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -126,24 +126,24 @@ "use strict"; | ||
// await this.send('Browser.close').then(data => { | ||
await this.send('Browser.close').then(data => { | ||
// // 返回错误消息时,强制退出chrome进程 | ||
// if (data.error) { | ||
// 返回错误消息时,强制退出chrome进程 | ||
if (data.error) { | ||
// consoln.warn('Browser.close消息响应超时,强制退出进程'); | ||
consoln.warn('Browser.close消息响应超时,强制退出进程'); | ||
// const { pid } = this.process; | ||
const { pid } = this.process; | ||
// // 强制杀死进程 | ||
// childProcess.execSync(`taskkill /pid ${pid} -f`); | ||
// windows 强制杀死进程 | ||
// childProcess.execSync(`taskkill /pid ${pid} -f`); | ||
// // this.process.kill(); | ||
// this.process.kill(); | ||
// } | ||
} | ||
// }) | ||
}) | ||
const { pid } = this.process; | ||
// const { pid } = this.process; | ||
// 强制杀死进程 | ||
childProcess.execSync(`taskkill /pid ${pid} -f`); | ||
// // windows 强制杀死进程 | ||
// childProcess.execSync(`taskkill /pid ${pid} -f`); | ||
@@ -150,0 +150,0 @@ } |
@@ -143,3 +143,3 @@ "use strict"; | ||
return await this.send('Target.getTargets') | ||
return await this.send('Target.getTargets'); | ||
@@ -146,0 +146,0 @@ } |
@@ -40,2 +40,2 @@ "use strict"; | ||
module.exports = Connection; | ||
module.exports = Connection; |
@@ -13,3 +13,3 @@ "use strict"; | ||
* @param {Function} page page实例 | ||
* @param {Object} message 远程element对象描述信息 | ||
* @param {Object} remote 节点远程对象 | ||
*/ | ||
@@ -51,3 +51,5 @@ constructor(page, remote) { | ||
const remote = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, selector) => { | ||
functionDeclaration: (element = document, selector) => { | ||
// console.log(element); | ||
// console.log(selector); | ||
return element.querySelector(selector); | ||
@@ -70,4 +72,3 @@ }, | ||
// 创建新的远程子节点实例 | ||
return this.create(remote); | ||
return this.create(remote); // 创建新的远程子节点实例 | ||
@@ -86,3 +87,3 @@ } | ||
const remote = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, selector) => { | ||
functionDeclaration: (element = document, selector) => { | ||
return element.querySelectorAll(selector) | ||
@@ -306,3 +307,6 @@ }, | ||
this.page.clicker.click(x, y) | ||
]) | ||
]).catch(error => { | ||
consoln.error(error); | ||
throw error; | ||
}) | ||
@@ -333,2 +337,2 @@ return result; | ||
module.exports = Element; | ||
module.exports = Element; |
@@ -21,10 +21,10 @@ "use strict"; | ||
const { objectId } = this.page.document; | ||
const { contextId: executionContextId } = this.page; | ||
if (objectId === undefined) { | ||
throw new Error(`缺少objectId参数!`); | ||
if (executionContextId === undefined) { | ||
throw new Error(`缺少executionContextId参数!`); | ||
} | ||
const { result, error } = await this.page.send('Runtime.callFunctionOn', { | ||
objectId, | ||
executionContextId, | ||
awaitPromise: true, | ||
@@ -31,0 +31,0 @@ userGesture: true, |
@@ -11,3 +11,3 @@ "use strict"; | ||
const { args = [], userDataDir, profileDir, } = options; | ||
const { headless, devtools, executablePath, } = options; | ||
const { headless, devtools, executablePath, timeOut } = options; | ||
@@ -35,2 +35,6 @@ if (userDataDir) { | ||
if (timeOut === undefined) { | ||
options.timeOut = 15000; | ||
} | ||
args.push('--remote-debugging-pipe'); | ||
@@ -37,0 +41,0 @@ |
@@ -120,2 +120,3 @@ "use strict" | ||
return description; | ||
} | ||
@@ -122,0 +123,0 @@ |
@@ -15,3 +15,3 @@ "use strict" | ||
class PageEvent extends EventEmitter { | ||
constructor() { | ||
constructor({ options }) { | ||
@@ -25,3 +25,3 @@ super(); | ||
this.loadPromise = new restartPromise(15000); | ||
this.loadPromise = new restartPromise(options.timeOut); | ||
@@ -117,6 +117,2 @@ } | ||
const { objectId } = await this.frame.evaluate({ expression: "document" }); | ||
this.document.objectId = objectId; | ||
this.contextId = id; | ||
@@ -180,3 +176,3 @@ | ||
this.once(name,async function (value) { | ||
this.once(name, async function (value) { | ||
@@ -183,0 +179,0 @@ if (callback) { |
{ | ||
"name": "auto-chrome", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "lib/", |
@@ -134,2 +134,4 @@ # auto-chrome | ||
* `timeOut` *Number* 消息响应超时时间,默认150000 | ||
* `ignoreHTTPSErrors` *Boolean* 忽略https错误,默认false | ||
@@ -136,0 +138,0 @@ |
86552
2027
439