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

用引导角AngularJS使用量角器测试

发布时间:2020-12-17 07:44:07 所属栏目:安全 来源:网络整理
导读:我想使用量角器测试我的角度应用程序.因为我使用RequireJS,我不能在我的DOM中使用ng-app指令,这就是为什么我用angular.bootstrap手动引导Angular. 量角器打印如下所示的错误输出: Error: Angular could not be found on the page http://localhost:1428/ :
我想使用量角器测试我的角度应用程序.因为我使用RequireJS,我不能在我的DOM中使用ng-app指令,这就是为什么我用angular.bootstrap手动引导Angular.

量角器打印如下所示的错误输出:

Error: Angular could not be found on the page http://localhost:1428/ : retries looking for angular exceeded

然后,我意识到量角器文档有一个警告:

Protractor does not work out-of-the-box with apps that bootstrap manually using angular.bootstrap. You must use the ng-app directive.

那么,手动启动角度应用程序是否有任何解决方法来运行量角器测试,还是应该开始了解替代测试套件?

去量角器配合并加上这个
onPrepare: function() {
// implicit and page load timeouts
  browser.manage().timeouts().pageLoadTimeout(40000);
  browser.manage().timeouts().implicitlyWait(25000);

  // for non-angular page
  browser.ignoreSynchronization = true;

  // sign in before all tests

}

它为我工作

我的完整配置文件看起来像这样…

// conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',specs: ['../**/*.e2e.js'],multiCapabilities: [{
browserName: 'firefox'
}],onPrepare: function() {
// implicit and page load timeouts
browser.manage().timeouts().pageLoadTimeout(40000);
browser.manage().timeouts().implicitlyWait(25000);

// for non-angular page
browser.ignoreSynchronization = true;

// sign in before all tests

 }
}

实际发生的是,您从量角器询问等待一段时间,并忽略document.ready(),以便您有时间手动引导角度.

(编辑:李大同)

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

    推荐文章
      热点阅读