-
Notifications
You must be signed in to change notification settings - Fork 0
/
automate.js
33 lines (32 loc) · 1.03 KB
/
automate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const { Chromeless } = require('chromeless')
const fs = require('fs')
const sharp = require('sharp')
const scale = () => {
return sharp().resize(400, 300)
}
async function run() {
const chromeless = new Chromeless()
const screenshot = await chromeless
.setViewport({ width: 1280, height: 800, scale: 1 })
.goto('https://secure.orson.io/fr/sessions/new')
.type('somepassword', 'input#user_password')
.click('div.callActionContainer input[type="submit"]')
.wait('div.bgSection')
.screenshot()
await chromeless
.wait(2000)
.click('a[data-method="delete"]')
console.log(screenshot)
// let readStream = fs.createReadStream(screenshot)
// let writeStream = fs.createWriteStream('screenshot.png')
// writeStream.on('close', () => {
// chromeless.end()
// })
// writeStream.on('error', error => {
// console.error(error)
// chromeless.end()
// })
await chromeless.end()// readStream.pipe(scale()).pipe(writeStream)
}
run().catch(console.error)