简体   繁体   English

量角器Angular 4 E2E测试异步

[英]Protractor Angular 4 E2E tests Async

I can't run E2E tests of an Angular 4 app without turning of Synchronization or telling it the app is not an Angular App 如果不打开同步或告诉它该应用程序不是Angular应用程序,则无法运行Angular 4应用程序的E2E测试

  browser.ignoreSynchronization = true;
  browser.waitForAngularEnabled(false);

when I don't do the above I get the following error: 当我不执行上述操作时,会出现以下错误:

- Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular

I have been running tests succesfully with either of the two commands, but I am getting more and more timeouts because I have to use waits and expected conditions to be able to get the page to load. 我已经成功使用这两个命令之一运行了测试,但是由于越来越多的超时,因为我必须使用等待和期望的条件才能加载页面,所以我越来越多。

The solution above is the only way I got my code to work, I haven't had any issues. 上面的解决方案是我的代码可以正常工作的唯一方法,我没有遇到任何问题。 As far as I understand AngularJS and Angular 4's async isn't the same and protractor was built for AngulaJS 据我了解,AngularJS和Angular 4的异步并不相同,量角器是为AngulaJS构建的

If I need to do a pause to wait for something to load I use: 如果需要暂停以等待加载,请使用:

const EC = protractor.ExpectedConditions;
      browser.wait(EC.presenceOf(foo), 5000, 'error: cant find foo');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM