Skip to content

Updates fennek from phantomjs/casperjs to chrome headless with puppeteer API

Notifications You must be signed in to change notification settings

jcayouette/fennek2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fennek2

Getting Started

Note: Puppeteer requires at least Node v6.4.0, but the examples below use async/await which is only supported in Node v7.6.0 or greater.

  1. Install npm10 on tumbleweed:

sudo zypper in npm10

  1. Install Puppeteer:

npm i puppeteer

  1. Install colors.js from npm https://www.npmjs.com/package/colors. This package is used to provide easy shortcuts to colored terminal output.

Example - Navigates to https://example.com and saves a screenshot as example.png.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();
  1. Save the file as example.js and execute the following on the command line:

node example.js

Capturing specific WebUI Elements:

// Systems : SSM Systems
    await page.waitFor(timeout);
    await page.goto(URL + 'rhn/systems/ssm/ListSystems.do');
    const ssmSystems = await page.$('#spacewalk-content');
    await ssmSystems.screenshot({path: systemsSSM + 'ssmSystems.png'});
    console.log('New screenshot generated in: '.bold + '/systemsPath/ssmSystems.png'.bgMagenta.bold);

For more informatin on working with the Google puppeteer API see:

https://github.com/GoogleChrome/puppeteer

You can also view the official API:

https://pptr.dev/

About

Updates fennek from phantomjs/casperjs to chrome headless with puppeteer API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published