加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 在电子中使用量角器

发布时间:2020-12-17 10:23:03 所属栏目:安全 来源:网络整理
导读:我正在尝试为 Electron使用 Electron运行的应用程序设置单元测试和e2e测试.我一直在参考许多不同的帖子( this one确实有帮助),但我仍然得到一个我不明白的错误: Message: Error while waiting for Protractor to sync with the page: "angular could not be
我正在尝试为 Electron使用 Electron运行的应用程序设置单元测试和e2e测试.我一直在参考许多不同的帖子( this one确实有帮助),但我仍然得到一个我不明白的错误:
Message:
  Error while waiting for Protractor to sync with the page: "angular could not be found on the window"
Stacktrace:
  undefined

我的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://");
    }
};

考虑到Protractor website上给出的文档,我的印象是我不需要安装任何其他东西(例如Jasmine).
让我感到惊讶的是,尽管main.js的路径(根据Electron的规格启动应用程序)是正确的,但我看不到弹出的Electron窗口中的任何内容.
你们有没有遇到过这个问题?你有设法解决它吗?

显然,使用电子二进制文件还不足以实际启动您的应用程序.但是,通过为应用程序构建二进制文件并将其链接到conf.js文件可以正常工作.
我已经能够将我的文件减少到这个:
conf.js
exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',specs: ['test-spec.js'],chromeOptions: {
            binary: "./dist/myAwesomeApp/myAwesomeAppBinary"
        }
    },onPrepare: function () {
        browser.resetUrl = "file://";
    }
};

通过这种方式,无需描述baseUrl或使用browser.get()或browser.driver.get()来启动Electron中的应用程序.但是,我宁愿不必构建应用程序二进制文件,但我认为现在不可能.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读