auto-chrome
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -252,4 +252,2 @@ const { sleep, signale } = require('./helper'); | ||
await this.focus() | ||
await sleep(600) | ||
@@ -256,0 +254,0 @@ |
@@ -118,15 +118,2 @@ const Message = require('./Message'); | ||
/** | ||
* 聚焦input元素 | ||
* @param {*} selector | ||
*/ | ||
async focus(selector) { | ||
let element = await this.$(selector) | ||
if (element) { | ||
await element.focus() | ||
return element | ||
} | ||
} | ||
/** | ||
* 通过选择器获取元素坐标 | ||
@@ -235,6 +222,23 @@ * @param {String} selector CSS选择器 | ||
/** | ||
* 聚焦input元素 | ||
* @param {String} selector | ||
*/ | ||
async focus(selector) { | ||
let element = await this.$(selector) | ||
if (element) { | ||
await element.focus() | ||
return element | ||
} | ||
} | ||
/** | ||
* 键盘入 | ||
* @param {*} selector CSS选择器 | ||
* @param {*} text 输入文本 | ||
* @param {*} options 附加选项 | ||
* @param {String} selector CSS选择器 | ||
* @param {String} text 输入文本 | ||
* @param {Object} options 附加选项 | ||
*/ | ||
@@ -241,0 +245,0 @@ async type(selector, text, options) { |
{ | ||
"name": "auto-chrome", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -14,11 +14,17 @@ const autoChrome = require('../..') | ||
await chrome.page.goto('http://www.runoob.com/') | ||
let page = chrome.page | ||
await sleep(3000) | ||
await page.goto('http://www.runoob.com/') | ||
await chrome.page.type('.search-desktop .placeholder', 'hellow word') | ||
await sleep(1000) | ||
let input = await page.$('.search-desktop .placeholder') | ||
await input.focus() | ||
await input.type('hellow word') | ||
await sleep(500) | ||
await chrome.keyboard.press("Enter") | ||
await page.keyboard.press("Enter") | ||
@@ -25,0 +31,0 @@ } |
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
566351
2760
25