auto-chrome
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -19,3 +19,3 @@ /** | ||
{ | ||
'name': 'Chrome', | ||
'name': 'Chrome 1920', | ||
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36', | ||
@@ -25,6 +25,25 @@ 'viewport': { | ||
'screenHeight': 1080, | ||
'mobile': false | ||
'width': 1920, | ||
'height': 969, | ||
} | ||
}, | ||
{ | ||
'name': 'Chrome 1680', | ||
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36', | ||
'viewport': { | ||
'screenWidth': 1680, | ||
'screenHeight': 1050, | ||
'width': 1680, | ||
'height': 939, | ||
} | ||
}, | ||
{ | ||
'name': 'Chrome 1366', | ||
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36', | ||
'viewport': { | ||
'screenWidth': 1366, | ||
'screenHeight': 768, | ||
} | ||
}, | ||
{ | ||
'name': 'iPad Pro', | ||
@@ -31,0 +50,0 @@ 'userAgent': 'Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1', |
@@ -129,4 +129,2 @@ "use strict"; | ||
await sleep(1000); | ||
} | ||
@@ -133,0 +131,0 @@ /** |
@@ -41,3 +41,3 @@ "use strict"; | ||
if (className === 'TypeError' || subtype === 'error') { | ||
logger.error(new Error(description)); | ||
logger.error(description); | ||
} | ||
@@ -44,0 +44,0 @@ |
@@ -162,4 +162,7 @@ "use strict" | ||
async type(text) { | ||
let chars = []; | ||
for (const char of text) { | ||
// 英文输入 | ||
@@ -177,3 +180,5 @@ if (keyDefinitions[char]) { | ||
} | ||
await sleep(100); | ||
} | ||
@@ -184,2 +189,3 @@ | ||
} | ||
} | ||
@@ -186,0 +192,0 @@ |
@@ -20,7 +20,7 @@ "use strict"; | ||
this.targetId = targetId; | ||
this.frame = new Frame(this); | ||
this.document = new Element(this); | ||
this.keyboard = new Keyboard(this); | ||
} | ||
@@ -37,6 +37,12 @@ /** | ||
if (viewport.mobile) { | ||
if (viewport.mobile === true) { | ||
this.clicker = new Touch(this); | ||
await this.send('Emulation.setDeviceMetricsOverride', { | ||
width: viewport.screenWidth, | ||
height: viewport.screenHeight, | ||
...viewport | ||
}); | ||
} else { | ||
@@ -46,12 +52,12 @@ | ||
await this.send('Emulation.setDeviceMetricsOverride', { | ||
width: viewport.screenWidth, | ||
height: Math.floor(viewport.screenHeight * 0.87), | ||
deviceScaleFactor: 0, | ||
mobile: false, | ||
...viewport | ||
}); | ||
} | ||
await this.send('Emulation.setDeviceMetricsOverride', { | ||
deviceScaleFactor: 0, | ||
mobile: false, | ||
width: viewport.screenWidth, | ||
height: Math.floor(viewport.screenHeight * 0.87), | ||
...viewport | ||
}) | ||
} else { | ||
@@ -63,2 +69,4 @@ | ||
this.chrome.clicker = this.clicker; | ||
if (geolocation) { | ||
@@ -248,3 +256,3 @@ | ||
return element; | ||
} | ||
@@ -251,0 +259,0 @@ |
@@ -24,3 +24,3 @@ "use strict" | ||
this.loadPromise = new restartPromise(10000); | ||
this.loadPromise = new restartPromise(15000); | ||
@@ -27,0 +27,0 @@ } |
{ | ||
"name": "auto-chrome", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "lib/", |
@@ -18,3 +18,3 @@ # auto-chrome | ||
* 支持消息队列等待超时自动解除,由于各种难以预料的情况,devtools并不保证100%对所有发送的消息做出回应,在没有超时机制的状态下消息将处于持续等待状态,导致任务无法继续执行 | ||
* 支持消息队列等待超时自动解除,由于各种不可控因素,devtools并不保证100%对所有发送的消息做出回应,在没有超时机制的状态下消息将处于持续等待状态,导致任务无法继续执行 | ||
@@ -73,11 +73,11 @@ * 解除鼠标、键盘、触控输入设备与页面的绑定,避免频繁在多个页面间切换设备 | ||
* 键盘、鼠标事件绑定了跳转连接的非链接元素触发导航行为 | ||
* 导航可能刷新当前标签,也可能创建新标签 | ||
* 导航可能在当前标签,也可能在新标签中加载 | ||
* 通过JS触发跳转链接的不可预测导航行为 | ||
* 点击链接后出现一次或多次301重定向 | ||
以上情况中,无法准确预判一个操作是否会触发导航。autoChrome中通过循环探测的方式来实现自动导航,该方案的缺点是时效不高,如果是已知的静态导航,用户可以自定义导航行为。 | ||
* 由于浏览器301缓存导致重定向的不确定性 | ||
有时候会出现连用户自己也无法确定某个操作是否会触发导航,比如当点击一个动态元素时会存在不确定性。 | ||
针对以上情况,无法准确预判一个操作是否会触发导航事件。autoChrome中通过循环探测的方式来实现自动导航,该方案的缺点是时效不高,应用场景有限。 | ||
@@ -148,16 +148,10 @@ ```js | ||
### chrome.keyboard | ||
### chrome.clicker | ||
鼠标操作,page.keyboard的快捷引用 | ||
mouse、touch事件实例,引用自当前活动状态page.clicker | ||
### chrome.mouse | ||
### chrome.keyboard | ||
鼠标操作,page.mouse的快捷引用 | ||
键盘事件实例,引用自当前活动状态page.keyboard | ||
### chrome.touch | ||
触控设备操作,page.touch的快捷引用 | ||
### chrome.touch | ||
### chrome.pages | ||
@@ -207,5 +201,5 @@ | ||
### page.mouse | ||
### page.clicker | ||
鼠标实例 | ||
mouse、touch事件实例,当autoChrome(options)配置项emulate.viewport.mobile值为true时,使用touch实例,否则使用mouse实例 | ||
@@ -216,6 +210,2 @@ ### page.keyboard | ||
### page.touch | ||
触控设备实例 | ||
### page.emulate(options) | ||
@@ -222,0 +212,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
85720
2008
438