Wrapper around Puppeteer library to make it easier to use.
In order to use this package you will need to install puppeteer first
npm i puppeteer
Note that you should have some knowledge of Puppeteer in order to use this tool.
Install puppeteer wrapper from npm
npm i puppeteerT4IT-wrapper
In order to use it you will need to require it first
const puppeteerT4IT = require('puppeteerT4IT-wrapper');
You can pass option
object as argument, which can contain all available option for puppeteer.launch() funciton. It returns new browser
instance.
let browser = await puppeteerT4IT.launch({ headless: false});
You can pass following arguments into this function:
browser
a browser instance which you have created with puppeteerT4IT.launch()authenticationData
object containing "username" and "password" keys for basic auth when the page is launched.
It returns 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 to (string)statusCode
awaited HTTP response status code (number)
It returns same browser page
as was passed in.
await puppeteerT4IT.goto(page, baseUrl);
You can pass following arguments into this function:
ms
time in ms to wait (number)
It returns empty promise.
await puppeteerT4IT.sleep(500);
You can pass following arguments into this function:
page
puppeteer page objectwidth
screen width (number)height
screen height (number)pageName
web page name under which screenshot will be stored (string)deviceScaleFactor
Specify device scale factor (can be thought of as dpr). Defaults to 1 (number)delay
Time in ms to wait after reloadbeforeAction
Function to be called before screenshot is made (function)beforeActionParameters
beforeAction parameters (array)
It returns empty promise.
await puppeteerT4IT.screenshotTest(page, 360, 640, name, 1, true, delay, beforeAction, beforeActionParameters);
You can pass following arguments into this function:
page
puppeteer page objectname
web page name under which screenshot will be stored (string)delay
Time in ms to wait after reload (number)beforeAction
Function to be called before screenshot is made (function)beforeActionParameters
beforeAction parameters (array)
It returns empty promise.
await puppeteerT4IT.screenshotMultipleResolutions(page, 'projects', 4000);
You can pass following arguments into this function:
page
puppeteer page objectquerySelector
page element selector (string)delay
Time in ms to wait after reload (number)
It returns empty promise.
await puppeteerT4IT.click(page, '.class', 500);
You can pass following arguments into this function:
page
puppeteer page objectquerySelector
page element selector (string)delay
Time in ms to wait after reload (number)
It returns empty promise.
await puppeteerT4IT.tapOnElement(page, '.class', 500);
You can pass following arguments into this function:
page
puppeteer page objectquerySelector
page element selector (string)
It returns link href from element.
await puppeteerT4IT.getLinkByQuerySelector(page, '.class');
You can pass following arguments into this function:
page
puppeteer page objectquerySelector
page element selector (string)
It returns link hostname from element.
await puppeteerT4IT.getHostnameByQuerySelector(page, '.class');
You can pass following arguments into this function:
page
puppeteer page objectquerySelector
page element selector (string)
It returns value of element.
await puppeteerT4IT.getValueByQuerySelector(page, '.class');
We use SemVer for versioning.
This project is licensed under the MIT License - see the LICENSE.md file for details.