• <tfoot id='SvGoo'></tfoot>

    <small id='SvGoo'></small><noframes id='SvGoo'>

    <legend id='SvGoo'><style id='SvGoo'><dir id='SvGoo'><q id='SvGoo'></q></dir></style></legend>
      <bdo id='SvGoo'></bdo><ul id='SvGoo'></ul>
  • <i id='SvGoo'><tr id='SvGoo'><dt id='SvGoo'><q id='SvGoo'><span id='SvGoo'><b id='SvGoo'><form id='SvGoo'><ins id='SvGoo'></ins><ul id='SvGoo'></ul><sub id='SvGoo'></sub></form><legend id='SvGoo'></legend><bdo id='SvGoo'><pre id='SvGoo'><center id='SvGoo'></center></pre></bdo></b><th id='SvGoo'></th></span></q></dt></tr></i><div id='SvGoo'><tfoot id='SvGoo'></tfoot><dl id='SvGoo'><fieldset id='SvGoo'></fieldset></dl></div>

      1. 使用 $resource 时量角器超时等待与页面同步

        时间:2023-10-12
          <tfoot id='J3j6b'></tfoot>

              <tbody id='J3j6b'></tbody>

              <small id='J3j6b'></small><noframes id='J3j6b'>

              • <bdo id='J3j6b'></bdo><ul id='J3j6b'></ul>
                <i id='J3j6b'><tr id='J3j6b'><dt id='J3j6b'><q id='J3j6b'><span id='J3j6b'><b id='J3j6b'><form id='J3j6b'><ins id='J3j6b'></ins><ul id='J3j6b'></ul><sub id='J3j6b'></sub></form><legend id='J3j6b'></legend><bdo id='J3j6b'><pre id='J3j6b'><center id='J3j6b'></center></pre></bdo></b><th id='J3j6b'></th></span></q></dt></tr></i><div id='J3j6b'><tfoot id='J3j6b'></tfoot><dl id='J3j6b'><fieldset id='J3j6b'></fieldset></dl></div>
                • <legend id='J3j6b'><style id='J3j6b'><dir id='J3j6b'><q id='J3j6b'></q></dir></style></legend>

                  本文介绍了使用 $resource 时量角器超时等待与页面同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在用一个小型 AngularJS 应用程序测试 Protractor.

                  I'm testing Protractor with a small AngularJS app.

                  这是测试:

                  describe('Testing Protractor', function() {
                    var draftList;
                  
                    it('should count the number of drafts', function() {
                      browser.get('#/');
                      draftList = element.all(by.repeater('newsletter in drafts'));
                      expect(draftList.count()).toEqual(2);
                    });
                  });
                  

                  控制器:

                  angular.module('myApp.controllers', []).
                    controller('DraftsCtrl', ['$scope', 'Draft', function($scope, Draft) {
                      $scope.drafts = Draft.query();
                  }])
                  

                  草稿服务:

                  angular.module('myApp.services', ['ngResource']).
                    factory('Draft', ['$resource',
                      function($resource) {
                        return $resource('api/drafts/:id')
                      }])
                  

                  使用 Protractor 运行此测试会导致以下错误:

                  Running this test using Protractor results in the following error:

                  Error: Timed out waiting for Protractor to synchronize with the page after 11 seconds
                  

                  但是,如果在控制器中我更改此行:

                  However, if in the controller I change this line:

                  $scope.drafts = Draft.query();
                  

                  到这里:

                  $scope.drafts = [];
                  

                  测试按预期失败,但更重要的是:它不会超时.

                  The test fails as expected, but more importantly: it does not time out.

                  启用 query() 后,无论是在浏览器中手动运行应用程序,还是查看 Protractor 打开的浏览器窗口时,API 返回的数据都会由中继器正确显示.

                  With query() enabled, both when running the app manually in a browser and when looking at the browser window opened by Protractor, the data returned by the API is correctly displayed by a repeater.

                  为什么服务与 API 通信时 Protractor 无法与页面同步?

                  Why is Protractor not able to synchronize with the page when the service is communicating with the API?

                  AngularJS 是 v1.2.0-rc3.量角器是 v0.12.0.

                  AngularJS is v1.2.0-rc3. Protractor is v0.12.0.

                  推荐答案

                  这是一个已知问题,但是有一个临时的解决方法.设置 ptor.ignoreSynchronization = true.

                  This is a known issue, but there is a temporary workaround. Set ptor.ignoreSynchronization = true.

                  例如:

                  describe('Testing Protractor', function() {
                    var draftList;
                    var ptor;
                  
                    beforeEach(function() {
                      ptor = protractor.getInstance();
                      ptor.ignoreSynchronization = true;
                    });
                  
                    it('should count the number of drafts', function() {
                      ptor.get('#/');
                      draftList = element.all(by.repeater('newsletter in drafts'));
                      expect(draftList.count()).toEqual(2);
                    });
                  });
                  

                  这篇关于使用 $resource 时量角器超时等待与页面同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:量角器 - 如何将一组承诺的结果放入另一个数组 下一篇:向元素发送 Ctrl+A 组合

                  相关文章

                  最新文章

                • <tfoot id='lKH9O'></tfoot>
                    <bdo id='lKH9O'></bdo><ul id='lKH9O'></ul>
                • <i id='lKH9O'><tr id='lKH9O'><dt id='lKH9O'><q id='lKH9O'><span id='lKH9O'><b id='lKH9O'><form id='lKH9O'><ins id='lKH9O'></ins><ul id='lKH9O'></ul><sub id='lKH9O'></sub></form><legend id='lKH9O'></legend><bdo id='lKH9O'><pre id='lKH9O'><center id='lKH9O'></center></pre></bdo></b><th id='lKH9O'></th></span></q></dt></tr></i><div id='lKH9O'><tfoot id='lKH9O'></tfoot><dl id='lKH9O'><fieldset id='lKH9O'></fieldset></dl></div>

                  <legend id='lKH9O'><style id='lKH9O'><dir id='lKH9O'><q id='lKH9O'></q></dir></style></legend>
                  1. <small id='lKH9O'></small><noframes id='lKH9O'>