macaca-playwright
TypeScript icon, indicating that this package has built-in type declarations

1.11.19 • Public • Published

macaca-playwright


NPM version CI Test coverage node version

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. Macaca Playwright is a long-term maintained browser driver as a candidate for Macaca Playwright driver.

Contributors


xudafeng


yihuineng


Jodeee


snapre


chen201724


ilimei

This project follows the git-contributor spec, auto updated at Thu Sep 21 2023 21:24:58 GMT+0800.

Installment

$ npm i macaca-playwright --save-dev

Usage as module

const fs = require('fs');
const path = require('path');
const Playwright = require('macaca-playwright');

const playwright = new Playwright();

async function() {
  /**
    default options
    {
      headless: false,
      x: 0,
      y: 0,
      width: 800,
      height: 600,
      userAgent: 'userAgent string'
    }
  */
  await playwright.startDevice({
    headless: true // in silence
  });

  await playwright.maximize();
  await playwright.setWindowSize(null, 500, 500);
  await playwright.get('https://www.baidu.com');
  const imgData = await playwright.getScreenshot();
  const img = new Buffer(imgData, 'base64');
  const p = path.join(__dirname, '..', 'screenshot.png')
  fs.writeFileSync(p, img.toString('binary'), 'binary');
  console.log(`screenshot: ${p}`);

  await playwright.stopDevice();
};

Readme

Keywords

Package Sidebar

Install

npm i macaca-playwright

Weekly Downloads

10

Version

1.11.19

License

MIT

Unpacked Size

74.2 kB

Total Files

14

Last publish

Collaborators

  • xudafeng
  • hugehard