Giter VIP home page Giter VIP logo

macaca-electron's Introduction

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

$ 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)

macaca-electron's People

Contributors

coffeedeveloper avatar cyjake avatar jacksonlai avatar meowtec avatar paradite avatar snapre avatar sriting avatar xianxiaow avatar xudafeng avatar yihuineng avatar ziczhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

macaca-electron's Issues

findElement and findElements does not work for classes

controllers.findElement = function * (strategy, selector, ctx) {
  return yield findElementOrElements.call(this, strategy, selector, ctx, false);
};

controllers.findElements = function * (strategy, selector, ctx) {
  return yield findElementOrElements.call(this, strategy, selector, ctx, true);
};

These two methods seem to work for finding elements based on id and name, but not classes.

Mcacac Electron 相关链接集合

Macaca

https://macacajs.github.io/macaca/
Macaca 官网

Electron

http://electron.atom.io/
Electron 是一款使用前端技术开发跨平台应用的框架

Hilo

http://hiloteam.github.io/
Hilo是一个跨终端的 HTML5 游戏解决方案

PhantomJS

http://phantomjs.org/
PhantomJS 是基于 webkit 的无头 JavaScript API

Macaca uitest

https://github.com/macacajs/uitest
基于 Macaca Electron 的网页端 UI 测试方案

Hiloteam - 使用Macaca进行单元测试

hiloteam/article#4
Hilo 团队的 UI 测试实践

demo error

22
按照demo 来截图 百度 首页 报错如上

多任务问题

在程序中期望多余一个测试案例同时在跑,

比如使用
let electron1 = new Electron();
let electron2 = new Electron();
let electron3 = new Electron();

结果是只能跑一个程序,剩下的要么报错

Timeout: Wait for message from the runner TIMEOUT.

要么没有响应。

求解答

未实现API

  • keyCode
  • close
  • getProperty
  • getWindow
  • getWindowSize

execute method in controllers assume array response contains elements

controllers.execute = function * (script, args) {
  if (!args) {
    args = [];
  }

  const value = yield sendJSCommand.call(this, 'execute_script', [
    script,
    args
  ], true);

  if (Array.isArray(value)) {
    return value.map(convertAtoms2Element.bind(this));
  } else {
    return value;
  }
};

This fails for simple task such as

var arrayResult = yield driver.execute('return [1, 2, 3]');
assert.equal(arrayResult, [1, 2, 3]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.