
Product
Announcing Bun and vlt Support in Socket
Bringing supply chain security to the next generation of JavaScript package managers
@touch4it/puppeteer
Advanced tools
Wrapper around Puppeteer library to make it easier to use.
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.
Install puppeteer wrapper from npm
npm i puppeteer @touch4it/puppeteer
or
npm i puppeteer-core @touch4it/puppeteer
In order to use it you will need to require it first
const puppeteerT4IT = require('@touch4it/puppeteer');
Returns Puppeteer library.
const puppeteer = puppeteerT4IT.getPuppeteer();
If you want to use different timeout and screenshot directory, you can use init function to change these variables. You can pass following arguments into this function:
timeout Default request timeout which will be use in the module (defaults to 30000 ms)screenshotDirectory Name of the directory where screenshots will be stored (defaults to screenshots/)puppeteerT4IT.init(5000, 'some_other_dir/');
You can pass option object as argument, which can contain all available option for launch() function
Returns new Browser instance.
let browser = await puppeteerT4IT.launch({ headless: false });
You can pass following arguments into this function:
browser A Browser instance that you have created with puppeteer.launch()authenticationData Object containing "username" and "password" authentication keys for basic auth when the page is launchedReturns new Page instance.
let page = await puppeteerT4IT.getPage(browser, { username: 'User', password: '123abc' });
You can pass following arguments into this function:
page Puppeteer page objecturl URL to be redirected tostatusCode awaited HTTP response status code (defaults to 200)Returns page
await puppeteerT4IT.goto(page, baseUrl);
You can pass following arguments into this function:
ms time in ms to waitReturns empty Promise
await puppeteerT4IT.sleep(500);
You can pass following arguments into this function:
page Puppeteer page objectwidth Screen widthheight Screen heightpageName Web page name under which a screenshot will be storeddeviceScaleFactor Specify device scale factor (Defaults to 1)isMobile isMobile Whether the meta viewport tag is taken into account (defaults to false)delay Time in ms to wait after reload (defaults to 0)beforeAction Function to be called before screenshot is made (defaults to null)beforeActionParameters beforeAction parameters (defaults to [])Returns empty Promise
await puppeteerT4IT.screenshotPage(page, 360, 640, 'frontpage', 1, true, delay, clickOnButton, ['.navigation-element--class']);
You can pass following arguments into this function:
page Puppeteer page objectname Web page name under which screenshots will be storeddelay Time in ms to wait after reload (defaults to 0)beforeAction Function to be called before screenshot is made (defaults to null)beforeActionParameters beforeAction parameters (defaults to [])Returns empty Promise
await puppeteerT4IT.screenshotMultipleResolutions(page, 'projects', 4000);
You can pass following arguments into this function:
page Puppeteer page objectquerySelector Page element selectordelay Time in ms to wait after reload (defaults to 0)Returns empty Promise
await puppeteerT4IT.click(page, '.class', 500);
You can pass following arguments into this function:
page Puppeteer page objectquerySelector Page element selectordelay Time in ms to wait after reload (defaults to 0)Returns empty Promise
await puppeteerT4IT.tapOnElement(page, '.class', 500);
You can pass following arguments into this function:
page Puppeteer page objectquerySelector Page element selectorReturns link href from element
await puppeteerT4IT.getLinkByQuerySelector(page, '.class');
You can pass following arguments into this function:
page Puppeteer page objectquerySelector Page element selectorIt returns link hostname from element.
await puppeteerT4IT.getHostnameByQuerySelector(page, '.class');
You can pass following arguments into this function:
page Puppeteer page objectquerySelector Page element selectorReturns value of element
await puppeteerT4IT.getValueByQuerySelector(page, '.class');
This project is licensed under the MIT License - see the LICENSE file for details.
Project updates are tracked in a CHANGELOG file
2.0.0 (2023-01-09)
FAQs
Wrapper around Puppeteer library to make it easier to use.
We found that @touch4it/puppeteer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies

Product
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.