auto-chrome
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -85,5 +85,5 @@ "use strict" | ||
await awaitOpen.then(function () { | ||
logger.success('Chrome 连接成功'); | ||
logger.success('Chrome连接成功'); | ||
}).catch(function (error) { | ||
logger.error(new Error('Chrome 连接失败')); | ||
logger.error(new Error('Chrome连接失败')); | ||
throw error | ||
@@ -90,0 +90,0 @@ }) |
@@ -19,3 +19,3 @@ "use strict" | ||
this.ws.on('message', this.listen.bind(this)) | ||
this.ws.on('message', this.message.bind(this)) | ||
@@ -52,3 +52,3 @@ this.createPromise = new timerPromise(2000, error => { | ||
*/ | ||
listen(data) { | ||
message(data) { | ||
@@ -55,0 +55,0 @@ const message = JSON.parse(data); |
@@ -17,5 +17,5 @@ "use strict" | ||
this.page = page | ||
this.frame = page.frame | ||
this.runtime = page.runtime | ||
if (!remote) return | ||
@@ -38,3 +38,3 @@ | ||
let remote = await this.runtime.callFunctionOn({ | ||
let remote = await this.frame.callFunctionOn({ | ||
functionDeclaration: () => document.body, | ||
@@ -67,3 +67,3 @@ }) | ||
let remote = await this.runtime.callFunctionOn({ | ||
let remote = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, selector) => { | ||
@@ -101,3 +101,3 @@ return element.querySelector(selector) | ||
let remote = await this.runtime.callFunctionOn({ | ||
let remote = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, selector) => { | ||
@@ -149,3 +149,3 @@ return element.querySelectorAll(selector) | ||
let result = await this.runtime.callFunctionOn({ | ||
let result = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, name) => element[name], | ||
@@ -167,3 +167,3 @@ arguments: [{ objectId }, { value: name }] | ||
let result = await this.runtime.callFunctionOn({ | ||
let result = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, name, value) => { | ||
@@ -187,3 +187,3 @@ return element[name] = value | ||
if (value) { | ||
var result = await this.runtime.callFunctionOn({ | ||
var result = await this.frame.callFunctionOn({ | ||
functionDeclaration: (element, value) => { | ||
@@ -195,3 +195,3 @@ return element.value = value | ||
} else { | ||
var result = await this.runtime.callFunctionOn({ | ||
var result = await this.frame.callFunctionOn({ | ||
functionDeclaration: element => element.value, | ||
@@ -212,3 +212,3 @@ arguments: [{ objectId }] | ||
let result = await this.runtime.callFunctionOn({ | ||
let result = await this.frame.callFunctionOn({ | ||
functionDeclaration: element => { | ||
@@ -215,0 +215,0 @@ let { x, y, width, height } = element.getBoundingClientRect() |
"use strict" | ||
const { logger, sleep } = require('./helper'); | ||
const Keyboard = require('./Keyboard'); | ||
const { Mouse, Touch } = require('./Clicker'); | ||
const Runtime = require('./Runtime'); | ||
const Frame = require('./Frame'); | ||
const Element = require('./Element'); | ||
const PageEvent = require('./PageEvent'); | ||
const { logger, sleep } = require('./helper'); | ||
class Page extends PageEvent { | ||
@@ -25,3 +26,3 @@ | ||
this.runtime = new Runtime(this) | ||
this.frame = new Frame(this) // 当前活动状态执行上下文 | ||
this.element = new Element(this) | ||
@@ -132,3 +133,3 @@ | ||
return await this.runtime.callFunctionOn({ | ||
return await this.frame.callFunctionOn({ | ||
functionDeclaration, | ||
@@ -203,3 +204,3 @@ arguments: args | ||
await this.runtime.callFunctionOn({ | ||
await this.frame.callFunctionOn({ | ||
functionDeclaration: element => { | ||
@@ -302,3 +303,3 @@ element.style.border = "1px solid #ed0000" | ||
let { value } = await this.runtime.evaluate({ | ||
let { value } = await this.frame.evaluate({ | ||
expression: "document.title" | ||
@@ -315,3 +316,3 @@ }) | ||
let { value } = await this.runtime.evaluate({ | ||
let { value } = await this.frame.evaluate({ | ||
expression: "window.location.href" | ||
@@ -318,0 +319,0 @@ }) |
@@ -114,6 +114,6 @@ "use strict" | ||
this.element.objectId = null | ||
this.contextId = context.id | ||
this.element.objectId = null | ||
this.ctxPromise.resolve() | ||
@@ -120,0 +120,0 @@ |
{ | ||
"name": "auto-chrome", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
573570
2852