Add waitforselector

This commit is contained in:
Vladimir Carrer 2019-01-05 13:58:18 +01:00
parent 37d63d8816
commit a33214dfe1
3 changed files with 7 additions and 2 deletions

View file

@ -28,6 +28,8 @@ screenshoteer --url file:///C:/Users/../Random-HTML-file.html
<p> <p>
Parameters: Parameters:
-h help
--url web page url --url web page url
--emulate - emulate web device example: --emulate "iPhone 6" --emulate - emulate web device example: --emulate "iPhone 6"
--fullpage - can be true or false. It will take screenshot of entire web page if is true. True is the default parameter. --fullpage - can be true or false. It will take screenshot of entire web page if is true. True is the default parameter.
@ -35,6 +37,7 @@ Parameters:
--w - width of the Web Page in px --w - width of the Web Page in px
--h - height of the Web Page in px --h - height of the Web Page in px
--waitfor - wait time for the page load in milliseconds --waitfor - wait time for the page load in milliseconds
--waitforselector - wait for the selector to appear in page
--el - css selector document.querySelector --el - css selector document.querySelector
--auth - basic http authentication --auth - basic http authentication
--no - exclude "image", "stylesheet", "script", "font" --no - exclude "image", "stylesheet", "script", "font"

View file

@ -12,6 +12,7 @@ program
.option('--w, [w]', 'width') .option('--w, [w]', 'width')
.option('--h, [h]', 'height') .option('--h, [h]', 'height')
.option('--waitfor, [waitfor]', 'Wait time in milliseconds') .option('--waitfor, [waitfor]', 'Wait time in milliseconds')
.option('--waitforselector, [waitforselector]', 'Wait for the selector to appear in page')
.option('--el, [el]', 'element css selector') .option('--el, [el]', 'element css selector')
.option('--auth, [auth]', 'Basic HTTP authentication') .option('--auth, [auth]', 'Basic HTTP authentication')
.option('--no, [no]', 'Exclude') .option('--no, [no]', 'Exclude')
@ -69,6 +70,7 @@ console.log(program.fullPage);
await page.goto(program.url); await page.goto(program.url);
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-'); const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
if (program.waitfor) await page.waitFor(Number(program.waitfor)); if (program.waitfor) await page.waitFor(Number(program.waitfor));
if (program.waitforselector) await page.waitForSelector(program.waitforselector);
if (program.click) await page.click(program.click); if (program.click) await page.click(program.click);
const file = program.file ? program.file : `${title} ${program.emulate} ${program.el} ${timestamp}.png`; const file = program.file ? program.file : `${title} ${program.emulate} ${program.el} ${timestamp}.png`;
if (program.el) { if (program.el) {

View file

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