Neverending Prototype Mode
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    macaca-electronpublic

    macaca-electron

    Gitter Chat NPM version build status Test coverage node version

    macaca electron driver

    Installment

    $ npm i macaca-electron -g

    Notice

    window.alert

    Macaca disables window.alert, window.prompt, window.confirm from popping up by default, and you can override by execute.

    Standalone usage

     
    const co = require('co');
    const fs = require('fs');
    const path = require('path');
    const Electron = require('macaca-electron');
     
    const electron = new Electron();
     
    co(function *() {
      /**
        default options
        {
          show: true,
          alwaysOnTop: false,
          x: 0,
          y: 0,
          width: 800,
          height: 600,
          userAgent: 'userAgent string',
          webPreferences: {
            nodeIntegration: false
          }
        }
      */
      yield electron.startDevice({
        show: false // in silence
      });
     
      yield electron.maximize();
      yield electron.setWindowSize(null, 500, 500);
      yield electron.get('https://www.baidu.com');
      const imgData = yield electron.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}`);
     
      yield electron.stopDevice();
    });
     

    License

    The MIT License (MIT)

    install

    npm i macaca-electron

    Downloadslast 7 days

    184

    version

    1.1.19

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar
    • avatar
    • avatar
    • avatar