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

@ -26,8 +26,10 @@ screenshoteer --url file:///C:/Users/../Random-HTML-file.html
<p>And with the help of puppeteer(Headless Chrome) it will generate screenshot of the entire web page.</p>
<p>
Parameters:
Parameters:
-h help
--url web page url
--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.
@ -35,6 +37,7 @@ Parameters:
--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
--waitforselector - wait for the selector to appear in page
--el - css selector document.querySelector
--auth - basic http authentication
--no - exclude "image", "stylesheet", "script", "font"

View File

@ -12,6 +12,7 @@ program
.option('--w, [w]', 'width')
.option('--h, [h]', 'height')
.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('--auth, [auth]', 'Basic HTTP authentication')
.option('--no, [no]', 'Exclude')
@ -69,6 +70,7 @@ console.log(program.fullPage);
await page.goto(program.url);
const title = (await page.title()).replace(/[/\\?%*:|"<>]/g, '-');
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);
const file = program.file ? program.file : `${title} ${program.emulate} ${program.el} ${timestamp}.png`;
if (program.el) {

View File

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