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

    1. <small id='Q5ng9'></small><noframes id='Q5ng9'>

      <legend id='Q5ng9'><style id='Q5ng9'><dir id='Q5ng9'><q id='Q5ng9'></q></dir></style></legend>
      • <bdo id='Q5ng9'></bdo><ul id='Q5ng9'></ul>
        <tfoot id='Q5ng9'></tfoot>
      1. 使用 $resource 时量角器超时等待与页面同步

        时间:2023-06-15

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

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

            <bdo id='tfAO0'></bdo><ul id='tfAO0'></ul>
                <tbody id='tfAO0'></tbody>

              <tfoot id='tfAO0'></tfoot>

              <legend id='tfAO0'><style id='tfAO0'><dir id='tfAO0'><q id='tfAO0'></q></dir></style></legend>
                1. 本文介绍了使用 $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 时量角器超时等待与页面同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

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

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

                    • <bdo id='KOHmj'></bdo><ul id='KOHmj'></ul>