Add new waitfor parameter

This commit is contained in:
Vladimir Carrer 2018-12-04 13:38:32 +01:00
parent 0a9eba44e5
commit 59ba221c0b
3 changed files with 4 additions and 1 deletions

View file

@ -28,6 +28,7 @@ Parameters:
--pdf - generate additional pdf
--w - width of the Web Page in px
--h - height of the Web Page in px
--waitfor - wait time for the page load in milliseconds
<p>

View file

@ -13,6 +13,7 @@ program
.option('--pdf, [pdf]', 'Generate PDF')
.option('--w, [w]', 'width')
.option('--h, [h]', 'height')
.option('--waitfor, [waitfor]', 'Wait time in milliseconds')
.parse(process.argv);
if (program.url) urlvalue = program.url
@ -33,6 +34,7 @@ console.log(fullPage);
if (program.w && program.h) await page.setViewport({width: Number(program.w), height: Number(program.h)})
if (program.emulate) await page.emulate(devices[program.emulate]);
await page.goto(urlvalue)
if (program.waitfor) await page.waitFor(Number(program.waitfor))
await page.screenshot({path: await page.title() + " " + program.emulate + " " + d.getTime() + '.png', fullPage: fullPage})
await page.emulateMedia('screen')
if (program.pdf) await page.pdf({ path: await page.title() + " " + program.emulate + " " + d.getTime() + '.pdf' })

View file

@ -1,6 +1,6 @@
{
"name": "screenshoteer",
"version": "1.0.0",
"version": "1.0.1",
"description": "Make screenshots and device emulations form your terminal",
"main": "index.js",
"scripts": {