我正在尝试为我运行的应用程序设置单元测试和 e2e 测试Electron http://electron.atom.io/ using 量角器 https://angular.github.io/protractor/#/。我参考了很多不同的帖子(this one https://github.com/nwjs/nw.js/issues/2229#issuecomment-53684702确实有帮助),但我仍然收到一个我不明白的错误:
Message:
Error while waiting for Protractor to sync with the page: "angular could not be found on the window"
Stacktrace:
undefined
My conf.js文件看起来像这样:
exports.config = {
directConnect : true,
seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl:"file://home/me/workspace/testing-project/main.js",
capabilities: {
browserName: "chrome",
chromeOptions: {
binary: "/home/me/.linuxbrew/lib/node_modules/electron-prebuilt/dist/electron",
args: ["--test-type=webdriver"]
}
},
specs: ['todo-specs.js'],
onPrepare: function(){
browser.resetUrl = "file://";
browser.driver.get("file://");
}
};
考虑到上给出的文档量角器网站 https://angular.github.io/protractor/#/,我的印象是我不需要安装任何其他东西(例如 Jasmine)。
令我惊讶的是,尽管通往main.js(根据 Electron 的规范启动应用程序)是正确的,我在弹出的 Electron 窗口中看不到任何内容。
你们有人遇到过这个问题吗?你设法解决了吗?
显然,使用电子二进制文件不足以实际启动您的应用程序。然而,通过building您的应用程序的二进制文件并将其链接到您的conf.js文件作品。
我已经能够将我的文件减少为:
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['test-spec.js'],
capabilities: {
browserName: "chrome",
chromeOptions: {
binary: "./dist/myAwesomeApp/myAwesomeAppBinary"
}
},
onPrepare: function () {
browser.resetUrl = "file://";
}
};
通过这样做,就不需要描述baseUrl
或使用browser.get()
nor browser.driver.get()
在 Electron 中启动应用程序。
但是,我宁愿不必构建应用程序二进制文件,但我认为目前不可能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)