Skip to content

Jodeee/macaca-playwright

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


snapre


Jodeee


ilimei


yihuineng

This project follows the git-contributor spec, auto updated at Fri Aug 19 2022 14:33:15 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();
};

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.8%
  • TypeScript 8.3%
  • HTML 3.6%
  • Shell 0.3%