Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/dom-capture

Package Overview
Dependencies
Maintainers
12
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/dom-capture

Library for scripts that run in the browser and extract information from web pages.

  • 5.0.1
  • npm
  • Socket score

Version published
Weekly downloads
376K
increased by8.65%
Maintainers
12
Weekly downloads
 
Created
Source

dom-capture

Library for scripts that run in the browser and extract information from web pages.

Installing

npm install @applitools/dom-capture

Using the package

This package exports 2 types of functions:

  1. Functions that can be used when working with puppeteer, CDP or Selenium in Node.js:

    • getProcessPageScript
    • getProcessPageAndSerializeScript
    • getCaptureDomScript

    These async functions return a string with a function that can be sent to the browser for evaluation. It doesn't immediately invoke the function, so the sender should wrap it as an IIFE. For example:

      const {getProcessPageScript} = require('@applitools/dom-capture');
      const processPageScript = await getProcessPageScript();
      const returnValue = await page.evaluate(`(${processPageScript})()`); // puppeteer
    
  2. The non bundled version of the scripts:

    • processPage
    • processPageAndSerialize

    These functions can then be bundled together with other client-side code so they are consumed regardless of a browser driver (this is how the Eyes.Cypress SDK uses it).

Usage from non-JavaScript code

This package's dist folder contains scripts that can be sent to the browser regradless of driver and language. An agent that wishes to extract information from a webpage can read the contents of dist/processPageAndSerialize and send that to the browser as an async script. There's still the need to wrap it in a way that invokes it.

For example in Java:

  Object response = driver.executeAsyncScript("const callback = arguments[arguments.length - 1];(" + processPageAndSerialize + ")().then(callback, err => callback(err.message))";

FAQs

Package last updated on 25 Nov 2018

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