Spectron 的新用户 ***
我正在尝试编写一个简单的测试来使用 Spectron 检查应用程序窗口计数。下面是代码。
const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron')
const path = require('path')
const { doesNotReject } = require('assert')
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
describe('Launch app', function() {
let app = new Application({
path: 'C:/Users/ts/Downloads/file.exe',
chromeDriverArgs: ["--disable-extensions"],
env: {
SPECTRON: true,
ELECTRON_ENABLE_LOGGING: true,
ELECTRON_ENABLE_STACK_DUMPING: true
},
connectionRetryCount:0
});
beforeEach(async () => {
this.timeout(5000);
await app.start();
});
it('Shows an initial window', async () => {
await app.client.waitUntilWindowLoaded();
await app.browserWindow.focus();
await app.browserWindow.setAlwaysOnTop(true);
await app.client.getWindowCount();
assert.equal(count, 1);
});
after(async () => {
await app.stop();
});
})
不幸的是,测试失败的原因很奇怪:
错误:超过 2000 毫秒的超时。对于异步测试和钩子,确保调用了“done()”;如果返回 Promise,请确保它已解决。
此外,我还看到多个黑色进程发送垃圾邮件,我无法捕捉应用程序窗口焦点。
感谢帮助!
谢谢