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

@automationcloud/cdp

Package Overview
Dependencies
Maintainers
4
Versions
248
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automationcloud/cdp

Chrome DevTools Protocol Driver

  • 32.11.0
  • npm
  • Socket score

Version published
Weekly downloads
253
decreased by-0.39%
Maintainers
4
Weekly downloads
 
Created
Source

Chrome DevTools Protocol Driver

See Chrome DevTools Protocol Viewer for all the awesome things you can do with your browser.

Installation

npm install --save @automationcloud/cdp

Usage

Launch Chrome/Chromium browser

import { ChromeLauncher } from '@automationcloud/cdp';

export const launcher = new ChromeLauncher({
    chromePort: 9123,
    chromePath: '/Applications/Chromium 72.app/Contents/MacOS/Chromium',
    userDataDir: '.tmp/chromedata',
    additionalArgs: [
        '--site-per-process',
        // add more chrome CLI args here, e.g. --proxy-server or --headless
    ],
});

// Launch chrome
await launcher.launch();

// Graceful shutdown (wait till Chrome process exits)
await launcher.shutdown();

// ... or just send SIGTERM to it
launcher.stop();

Connect to browser via CDP

import { Browser } from '@automationcloud/cdp';

const browser = new Browser({
    chromePort: 9123,
});

await browser.connect();
const tab = await browser.newTab();
await tab.navigate('https://github.com');
const h1 = await tab.querySelector('h1');
const { text } = await h1.getInfo();
// Built for developers

Running tests

  • Copy .env.example to .env.
  • Specify environment variables (notably, the path to Chromium browser)
  • Note: you should not use your regular browser for testing, install a separate one which you don't normally use.
  • Note: make sure you don't have test browser running before running the tests.
  • Run npm run dev in separate terminal for incremental TypeScript compilation (in case you want to iterate on the tests or source code).
  • Run npm test.

FAQs

Package last updated on 05 Oct 2020

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