【发布时间】:2018-09-03 18:48:39
【问题描述】:
请详细告诉我..
我有一个电子应用程序,我有那个 exe .. 但想使用量角器框架自动化。
指导我。
【问题讨论】:
-
Hi Shyam 你破解了解决方案吗?
标签: testing protractor
请详细告诉我..
我有一个电子应用程序,我有那个 exe .. 但想使用量角器框架自动化。
指导我。
【问题讨论】:
标签: testing protractor
您应该尝试使用 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
【讨论】: