【问题标题】:how to automate electron exe file using protractor framework如何使用量角器框架自动化电子 exe 文件
【发布时间】:2018-09-03 18:48:39
【问题描述】:

请详细告诉我..

我有一个电子应用程序,我有那个 exe .. 但想使用量角器框架自动化。

指导我。

【问题讨论】:

  • Hi Shyam 你破解了解决方案吗?

标签: testing protractor


【解决方案1】:

您应该尝试使用 Spectron

https://electronjs.org/spectron

Spectron 是一款电子应用测试工具。可以打包成exe文件后进行测试,也可以直接通过main.js开始测试

npm install --save-dev spectron

通过 npm 安装 spectron。下面的示例使用 mocha 进行断言。

从命令行启动并运行:

在本地安装 mocha 作为开发依赖项。

npm i mocha -D

创建一个如下所示的规范文件

const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron') 
const path = require('path')
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');


 global.before(() => {
     chai.should();
     chai.use(chaiAsPromised);
  });


describe('Application launch', function () {
  this.timeout(10000)

  beforeEach(function () {
     const opts = {
  path: './your.exe'
};
const app = new Application(opts);
return app.start().then((app) => {
  chaiAsPromised.transferPromiseness = app.transferPromiseness;
  return app;

      })
  })

  afterEach(function () {
    if (this.app && this.app.isRunning()) {
      return this.app.stop()
    }
  })

  it('shows an initial window', function () {
    return this.app.client.getWindowCount().then(function (count) {
      assert.equal(count, 1)
      // Please note that getWindowCount() will return 2 if `dev tools` are opened.
      // assert.equal(count, 2)
    })
  })
})

通过以下方式运行测试:

mocha spec.js

【讨论】:

  • 感谢您的建议,但我的任务是仅使用量角器。所以告诉我用那个。
  • 实际上它不起作用,这就是我重新发布问题的原因。
  • 它启动应用程序,但不让规范文件工作.. 它说 chrome 无法访问
猜你喜欢
  • 2020-04-28
  • 2016-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-19
  • 1970-01-01
  • 1970-01-01
  • 2018-07-25
相关资源
最近更新 更多