【发布时间】:2018-07-31 15:12:58
【问题描述】:
背景:我目前正在尝试从 Angular Electron 应用程序内部实现基本的WebdriverIO example。我的应用程序基于Angular Electron Boilerplate。我已经通过 npm 安装了 webdriverio 和 @types/webdriverio。然后我创建了以下服务:
import { Injectable } from '@angular/core';
import { remote, Options } from 'webdriverio';
@Injectable()
export class WebdriverioService {
remote: typeof remote;
options: Options;
constructor() {
this.options = {
desiredCapabilities: {
browserName: 'chrome'
}
}
}
test(): void {
remote(this.options) // <-- this line causes the error
.init()
.url('http://www.google.com')
.getTitle().then(function (title) {
console.log('Title was: ' + title);
})
.end()
.catch(function (err) {
console.log(err);
});
}
}
我已用评论标记了关键行。首先,我收到以下编译器警告:
WARNING in ./node_modules/webdriverio/build/lib/launcher.js
138:39-55 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/webdriverio/build/lib/utils/ConfigParser.js
144:58-75 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/webdriverio/build/lib/helpers/getImplementedCommands.js
59:44-90 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/webdriverio/build/lib/launcher.js
812:34-50 Critical dependency: the request of a dependency is an expression
其次我的应用程序抛出以下错误:
Uncaught Error: ENOENT, protocol not found in <<Path to App>>\node_modules\electron\dist\resources\electron.asar
at notFoundError (ELECTRON_ASAR.js:114)
at Object.fs.readdirSync (ELECTRON_ASAR.js:588)
at getImplementedCommands (getImplementedCommands.js:40)
at Object../node_modules/webdriverio/build/index.js (index.js:59)
at __webpack_require__ (bootstrap:76)
at Object../src/app/providers/webdriverio.service.ts (electron.service.ts:10)
at __webpack_require__ (bootstrap:76)
at Object../src/app/app.module.ts (app.component.ts:11)
at __webpack_require__ (bootstrap:76)
at Object../src/main.ts (environment.ts:4)
我认为这个问题似乎主要与 typescript 配置有关,但我不放心。我真的不知道在哪里看。有人能告诉我我忘记了什么吗?
【问题讨论】:
标签: angular typescript electron webdriver-io