auto-chrome
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -101,2 +101,11 @@ "use strict" | ||
/** | ||
* 创建新的Element实例 | ||
* @param {Object} remote 远程资源对象 | ||
*/ | ||
create(objectId) { | ||
return new Element(this.page, { objectId }) | ||
} | ||
/** | ||
* CSS单选迭代选择器 | ||
@@ -107,4 +116,3 @@ * @param {String} selector | ||
// 子查询 | ||
let { objectId, className, description } = await this.evaluate({ | ||
let remote = await this.evaluate({ | ||
func: (element, selector) => element.querySelector(selector), | ||
@@ -114,4 +122,6 @@ args: [{ value: selector }] | ||
let { objectId, className, description } = remote | ||
if (className === 'TypeError') { | ||
logger.error(new Error(description)) | ||
logger.warn(new Error(description)) | ||
return | ||
@@ -123,3 +133,3 @@ } | ||
// 创建新的子节点实例 | ||
return new Element(this.page, { objectId }) | ||
return this.create(objectId) | ||
@@ -149,6 +159,7 @@ } | ||
// 批量创建子节点实例 | ||
for (let item of result) { | ||
if (item.enumerable === true) { | ||
// 批量创建子节点实例 | ||
let element = new Element(this.page, item.value) | ||
let { enumerable, value } = item | ||
if (enumerable === true) { | ||
let element = this.create(value.objectId) | ||
elements.push(element) | ||
@@ -186,3 +197,3 @@ } | ||
return await this.evaluate({ | ||
let { value } = await this.evaluate({ | ||
args: [{ value: name }, { value }], | ||
@@ -194,5 +205,7 @@ func: (element, name, value) => { | ||
return value | ||
} | ||
/** | ||
* 获取或设置值 | ||
* 获取或设置值,仅适用于input元素 | ||
* @param {*} selector | ||
@@ -203,3 +216,3 @@ */ | ||
if (value) { | ||
return await this.evaluate({ | ||
var result = await this.evaluate({ | ||
func: (element, value) => { element.value = value }, | ||
@@ -209,3 +222,3 @@ args: [{ value }] | ||
} else { | ||
return await this.evaluate({ | ||
var result = await this.evaluate({ | ||
func: element => element.value | ||
@@ -215,2 +228,4 @@ }) | ||
return result.value | ||
} | ||
@@ -217,0 +232,0 @@ /** |
@@ -176,2 +176,4 @@ "use strict" | ||
return element | ||
} | ||
@@ -178,0 +180,0 @@ |
{ | ||
"name": "auto-chrome", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
566751
2707