Socket
Socket
Sign inDemoInstall

pptr-plus

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pptr-plus

Some extra functions which are missing in the Puppeteer (pptr.dev) library.


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

pptr-plus

Some extra functions which are missing in the Puppeteer (pptr.dev) library.

Installation

$ npm install --save pptr-plus

Example

/*** NodeJS script ***/
const PptrPlus = require('pptr-plus');
const pp = new PptrPlus(page);
await pp.checkTextOnPage('Bitcoin goes up')

API

constructor(page)

The page argument is the puppeteer Page instance (object).

  const browser = await puppeteer.launch(sysconfig.puppeteer).catch(err => echo.error(err));
  // const page = await browser.newPage(); // open page in the second tab
  const page = (await browser.pages())[0]; // open page in the first tab
async autoscroll(cssSel, delay = 3400)

Autoscroll the web page where content is loaded dynamically as the user scroll down. For example the facebook posts. Scroll vertically to the last element. The scroll will stop when the text content of the last element is equal to the previous element text content. What means there's no new content on the page.

  • @param {string} cssSel - CSS selector of the last repetitive content, for example table > tbody > tr:last-child
  • @param {number} delay - the time interval between every consecutive scroll
async scrollToBottom(delay = 100)

Scroll the web page to bottom. The page will scroll for innerHeight for every delay miliseconds until it reach the end.

  • @param {number} delay - the time interval between every consecutive scroll
async selectOptionByText(sel, txt)

Click the SELECT tag and then click OPTION with the text

  • @param {string} sel - css selector for SELECT tag
  • @param {string} txt - text contained in the OPTION tag
async selectOptionByValue(sel, val)

Select the option by the value

  • @param {string} sel - css selector for SELECT tag
  • @param {string} val - the OPTION tag value attribute
async clickElemWithText(xPath, txt, exactMatch)

Click the element defined by the xPath which contains text

  • @param {string} xPath - part of the xPath - //ul[@id="allBsnsList"]/li/a
  • @param {string} txt - text contained in the HTML element
  • @param {boolean} exactMatch - if true find exact word match
async clickElemWithText_bubles(xPath, txt, exactMatch)

Click the element defined by the xPath which contains text

  • @param {String} xPath - part of the xPath - //ul[@id="allBsnsList"]/li/a
  • @param {Object} txt - text contained in the HTML element
  • @param {Boolean} exactMatch - if true find exact word match
checkTextOnPage(txt)

Check if the text is contained on the page.

  • @param {string} txt - text contained in the whole page's HTML
async waitURLContains(txt)

Wait for the URL which contains "txt" pattern.

  • @param {string} txt - text contained in the URL
async inputClear(sel)

Clear the input field. Useful before typing new value into the INPUT text field.

  • @param {string} sel - css selector of the INPUT filed
async inputType(sel, val)

Fill the input field by typing into it

  • @param {string} sel - css selector
  • @param {string} val - input value
async saveScreenshot(dirPath, fileName)

Create the screenshot image and save it into the folder. The file will be saved as .jpg.

  • @param {string} dirPath - path to the directory where screenshot will be saved, for example '../../tmp/screenshots/progressive_commercialAuto/'
  • @param {string} fileName - the screenshot file name, for example 'myScreenshot.jpg' or just 'myScreenshot'
async cookieSave(cookie_file_path)

Save cookie data from browser to file.

  • @param {string} cookie_file_path - dir/fileName.json
async cookieTake(cookie_file_path)

Get cookie data from the file and set browser's cookie.

  • @param {string} cookie_file_path - dir/fileName.json
async storageSave(storage_file_path, storage_type)

Save local or session storage data from browser to file.

  • @param {string} storage_file_path - dir/fileName.json
  • @param {string} storage_type - 'localStorage' | 'sessionStorage'
async storageTake(storage_file_path, storage_type)

Get storage data from the file and set browser's loal or session storage.

  • @param {string} storage_file_path - dir/fileName.json
  • @param {string} storage_type - 'localStorage' | 'sessionStorage'

License

The software licensed under AGPL-3.

Keywords

FAQs

Package last updated on 18 Oct 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc