我的角电子应用具有以下结构:
Application-folder:
electron-folder
src-folder(conataing angular code)
test (containing spectron test file)
当它们位于同一“应用程序”文件夹中时,此方法工作正常。现在,我想将这种电子应用程序与安装在同一台机器上的独立光谱应用程序分开。为此,我从上述应用程序测试文件夹中取出了spectron测试文件。创建另一个应用程序。所以现在我有两个应用程序。我将上述应用程序中的Spectron测试文件放入了新创建的应用程序中,并进行了如下配置:
process.env.ENVIRONMENT = 'TEST';
const winston = require('winston');
const Application = require('spectron').Application;
const assert = require('assert');
// const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
const path = require('path');
const app = new Application({
path: 'C:/Users/sprint_2/node_modules/.bin/electron', //path to node modules electron binary of another application which I want to access
args: ['C:/Users/sprint_2/electron/main.ts'] //path to main.ts of other application which I want to access
});
describe('Automation: Launch Desktop Application', function() {
this.timeout(1000000);
before(() => {
// start electron application
return app.start();
});
afterEach(done => setTimeout(done, 1000));
after(() => {
if (app && app.isRunning()) {
logger.info('Automation: Desktop Application closed');
// close electron application
return app.stop();
}
});
it('initialize electron desktop application', () => {
return app.client.getWindowCount().then((count) => {
assert.equal(count, 1);
});
});
//Now automated test case starts
在运行上述代码时,出现以下错误:
1) "before all" hook for "initialize electron desktop application"
0 passing (31s)
1 failing
1) Automation: Launch Desktop Application
"before all" hook for "initialize electron desktop application":
Client initialization failed after 10 attempts: RuntimeError Client initialization failed after 10 attempts:
Error: unknown error: Chrome failed to start: exited normally
(chrome not reachable)
(The process started from chrome location C:\Users\sprint_2\spectron\node_modules\spectron\lib\launcher.bat is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=69.0.3497.106 (857b284701ddf7bef0f14fa76416cf7ca786b411),platform=Windows NT 6.1.7601 SP1 x86_64)
at new RuntimeError (node_modules\webdriverio\build\lib\utils\ErrorHandler.js:143:12)
at Request._callback (node_modules\webdriverio\build\lib\utils\RequestHandler.js:318:39)
at Request.self.callback (node_modules\request\request.js:185:22)
at Request.EventEmitter.emit (domain.js:448:20)
at Request.<anonymous> (node_modules\request\request.js:1161:10)
at Request.EventEmitter.emit (domain.js:448:20)
at IncomingMessage.<anonymous> (node_modules\request\request.js:1083:12)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1129:12)