18.0.2 • Published 2 years ago

macaca-electron v18.0.2

Weekly downloads
214
License
MIT
Repository
github
Last release
2 years ago

macaca-electron

NPM version Package quality build status Test coverage node version

Macaca Electron driver

Contributors

xudafengparaditemeowtecziczhuxianxiaowcyjake
coffeedeveloperjacksonlaisritingsnapreyihuineng

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

Installment

$ 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

const fs = require('fs');
const path = require('path');
const Electron = require('macaca-electron');

const electron = new Electron();

/**
  default options
  {
    show: true,
    alwaysOnTop: false,
    x: 0,
    y: 0,
    width: 800,
    height: 600,
    userAgent: 'userAgent string',
    webPreferences: {
      nodeIntegration: false
    }
  }
*/
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

(async () => {
  await electron.startDevice({
    show: false // in silence
  });
  await electron.maximize();
  await electron.setWindowSize(null, 500, 500);
  await electron.get('https://www.baidu.com');
  await sleep(3000);
  const imgData = await electron.getScreenshot();
  const img = Buffer.from(imgData, 'base64');
  const p = path.join('screenshot.png');
  fs.writeFileSync(p, img.toString('binary'), 'binary');
  console.log(`screenshot: ${p}`);

  await electron.stopDevice();
})();

License

The MIT License (MIT)

18.0.2

2 years ago

17.1.0

3 years ago

17.2.0

3 years ago

17.0.2

3 years ago

18.0.0

3 years ago

17.0.1

3 years ago

17.0.0

3 years ago

13.0.2

3 years ago

13.0.0

3 years ago

13.0.1

3 years ago

11.1.4

3 years ago

11.1.3

3 years ago

11.1.1

3 years ago

11.1.2

3 years ago

11.1.0

3 years ago

11.0.1

4 years ago

11.0.0

4 years ago

9.0.3

4 years ago

9.0.2

4 years ago

9.0.1

4 years ago

9.0.0

4 years ago

7.0.4

5 years ago

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

2.2.5

5 years ago

3.0.2

6 years ago

3.0.0

6 years ago

2.2.4

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

2.1.4

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.10

8 years ago

1.0.8

8 years ago

1.0.9

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.0

9 years ago