auto-chrome
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -141,9 +141,6 @@ const { assert, sleep } = require('./helper'); | ||
async type(text, options = {}) { | ||
let delay = 30; | ||
if (options.delay) { | ||
delay = options.delay; | ||
} | ||
let { delay = 60 } = options | ||
for (const char of text) { | ||
if (keyDefinitions[char]) | ||
await this.press(char, { delay }); | ||
await this.press(char, { delay: 20 }); | ||
else | ||
@@ -150,0 +147,0 @@ await this.sendCharacter(char); |
const Message = require('./Message'); | ||
const Elment = require('./Elment'); | ||
const Element = require('./Element'); | ||
const { Keyboard, Mouse, Touch } = require('./Input'); | ||
@@ -93,5 +93,5 @@ const { sleep, signale } = require('./helper'); | ||
let element = new Elment(this) | ||
let element = new Element(this) | ||
let el = element.$(selector) | ||
let el = await element.$(selector) | ||
@@ -109,3 +109,3 @@ if (el) { | ||
let element = new Elment(this) | ||
let element = new Element(this) | ||
@@ -125,6 +125,7 @@ let el = element.$$(selector) | ||
return await this.evaluate(function (selector) { | ||
let input = document.querySelector(selector) | ||
input.focus() | ||
}, selector) | ||
let element = await this.$(selector) | ||
if (element) { | ||
await element.focus() | ||
return element | ||
} | ||
@@ -180,13 +181,2 @@ } | ||
/** | ||
* 表单输入 | ||
* @param {String} text | ||
*/ | ||
async type(text, options) { | ||
await sleep(600) | ||
return await this.keyboard.type(text, options) | ||
} | ||
/** | ||
* 滚动元素至指定元素 | ||
@@ -248,2 +238,21 @@ * @param {String} selector | ||
/** | ||
* 键盘入 | ||
* @param {*} selector CSS选择器 | ||
* @param {*} text 输入文本 | ||
* @param {*} options 附加选项 | ||
*/ | ||
async type(selector, text, options) { | ||
let element = await this.$(selector) | ||
if (element) { | ||
await element.type(text, options) | ||
return element | ||
} | ||
} | ||
/** | ||
* 关闭标签 | ||
@@ -250,0 +259,0 @@ */ |
{ | ||
"name": "auto-chrome", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -200,15 +200,2 @@ # auto-chrome | ||
#### page.focus(selector) | ||
通过CSS选择器聚焦元素 | ||
* `selector` *String* CSS选择器 | ||
#### page.getBoundingRect(selector) | ||
通过CSS选择器获取元素坐标,值由getBoundingClientRect()函数获取 | ||
* `selector` *String* CSS选择器 | ||
#### page.click(selector) | ||
@@ -230,3 +217,3 @@ | ||
* `options.delay` *Number* 输入间隔时间,ms | ||
* `delay` *Number* 输入间隔时间,ms | ||
@@ -260,2 +247,14 @@ #### page.scroll(selector) | ||
#### page.focus(selector) | ||
通过CSS选择器聚焦元素 | ||
* `selector` *String* CSS选择器 | ||
#### page.getBoundingRect(selector) | ||
通过CSS选择器获取元素坐标,值由getBoundingClientRect()函数获取 | ||
* `selector` *String* CSS选择器 | ||
#### page.close() | ||
@@ -271,3 +270,3 @@ | ||
对于大的对象或DOM对象,直接返回它们并不现实,因此需要一种远程操作的增量机制。devtools通过保存注入函数的执行结果并生成查询id,实现状态追踪,这样就可以在已有远程结果基于上做增量操作。 | ||
对于大的对象或DOM对象,直接返回它们并不现实,因此需要一种远程操作的增量机制。devtools通过保存注入函数的执行结果并返回引用id,实现状态追踪,这样就可以在已有远程结果基于上做增量操作。 | ||
@@ -274,0 +273,0 @@ #### elment.$(selector) |
@@ -16,8 +16,6 @@ const autoChrome = require('../../') | ||
await sleep(3000) | ||
await sleep(1000) | ||
await chrome.page.focus('#input') | ||
await chrome.page.type('#input', 'hellow word') | ||
await chrome.page.type('hellow word') | ||
await sleep(500) | ||
@@ -24,0 +22,0 @@ |
@@ -26,2 +26,4 @@ const autoChrome = require('../..') | ||
run() | ||
run().catch(function (error) { | ||
console.log(error) | ||
}) |
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
566271
45
2758
383