项目作者: macacajs

项目描述 :
:electron: Macaca Electron driver
高级语言: JavaScript
项目地址: git://github.com/macacajs/macaca-electron.git
创建时间: 2016-03-29T07:41:52Z
项目社区:https://github.com/macacajs/macaca-electron

开源协议:MIT License

下载


macaca-electron

NPM version
Package quality
build status
Test coverage
node version

Macaca Electron driver

Contributors


xudafeng


paradite


meowtec


ziczhu


xianxiaow


cyjake


coffeedeveloper

|
jacksonlai

|
sriting

|
snapre

|
yihuineng

This project follows the git-contributor spec, auto updated at Sat May 07 2022 23:36:31 GMT+0800.

Installment

  1. $ npm i macaca-electron -g

Release Plan

Simply put, Chromium doesn’t stop shipping so Electron is not going to slow down either, so Macaca is not stop…

Starting with Electron version 7, Macaca will always upgrade with the Electron’s main version.

Environment Variable

set MACACA_ELECTRON_DEVTOOLS=1 to open the devtools.

Notice

window.alert

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

Standalone usage

  1. const fs = require('fs');
  2. const path = require('path');
  3. const Electron = require('macaca-electron');
  4. const electron = new Electron();
  5. /**
  6. default options
  7. {
  8. show: true,
  9. alwaysOnTop: false,
  10. x: 0,
  11. y: 0,
  12. width: 800,
  13. height: 600,
  14. userAgent: 'userAgent string',
  15. webPreferences: {
  16. nodeIntegration: false
  17. }
  18. }
  19. */
  20. const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
  21. (async () => {
  22. await electron.startDevice({
  23. show: false // in silence
  24. });
  25. await electron.maximize();
  26. await electron.setWindowSize(null, 500, 500);
  27. await electron.get('https://www.baidu.com');
  28. await sleep(3000);
  29. const imgData = await electron.getScreenshot();
  30. const img = Buffer.from(imgData, 'base64');
  31. const p = path.join('screenshot.png');
  32. fs.writeFileSync(p, img.toString('binary'), 'binary');
  33. console.log(`screenshot: ${p}`);
  34. await electron.stopDevice();
  35. })();

License

The MIT License (MIT)