久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='ZyF8Z'></bdo><ul id='ZyF8Z'></ul>

      <tfoot id='ZyF8Z'></tfoot>
    1. <small id='ZyF8Z'></small><noframes id='ZyF8Z'>

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

      如何使用量角器在 e2e 測(cè)試中預(yù)期元素的動(dòng)態(tài)計(jì)數(shù)

      How to expect dynamic count of elements in e2e tests using Protractor(如何使用量角器在 e2e 測(cè)試中預(yù)期元素的動(dòng)態(tài)計(jì)數(shù))
          <legend id='cRQTm'><style id='cRQTm'><dir id='cRQTm'><q id='cRQTm'></q></dir></style></legend>
          • <bdo id='cRQTm'></bdo><ul id='cRQTm'></ul>
            <i id='cRQTm'><tr id='cRQTm'><dt id='cRQTm'><q id='cRQTm'><span id='cRQTm'><b id='cRQTm'><form id='cRQTm'><ins id='cRQTm'></ins><ul id='cRQTm'></ul><sub id='cRQTm'></sub></form><legend id='cRQTm'></legend><bdo id='cRQTm'><pre id='cRQTm'><center id='cRQTm'></center></pre></bdo></b><th id='cRQTm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cRQTm'><tfoot id='cRQTm'></tfoot><dl id='cRQTm'><fieldset id='cRQTm'></fieldset></dl></div>

              <tfoot id='cRQTm'></tfoot>

            • <small id='cRQTm'></small><noframes id='cRQTm'>

                  <tbody id='cRQTm'></tbody>
              • 本文介紹了如何使用量角器在 e2e 測(cè)試中預(yù)期元素的動(dòng)態(tài)計(jì)數(shù)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我目前正在使用 Protractor 為我不起眼的 Angular 應(yīng)用程序編寫一些 e2e 測(cè)試.

                I'm currently writing some e2e tests for my humble Angular app with Protractor.

                我的應(yīng)用程序運(yùn)行良好,單元測(cè)試通過了所有測(cè)試,也使用了 e2e...直到這個(gè):

                My app works fine, unit tests passes all, e2e used too... until this one:

                appE2ESpec.js

                describe('adding an item', function() {
                  var items,
                      addItemButton,
                      startCount;
                
                  beforeEach(function() {
                    items = element.all(by.css('li.item'));
                    addItemButton = element(by.id('addItemButton'));
                    startCount = items.count();
                  });
                
                  it('should display a new item in list', function() {
                    addItemButton.click();
                
                    expect(items.count()).toEqual(startCount+1);
                  });
                });
                

                這就是我編寫測(cè)試的方式,但是,

                This is how I would have written my test but,

                問題是: items.count() 返回一個(gè)承諾,我知道,但我無法強(qiáng)制 Protractor 解決它.所以我明白了:

                The problem is: that items.count() returns a promise, I know that, but I can't manage to force Protractor to resolve it. So I get this:

                Failures:
                
                1) myApp adding an item should display a new item in list
                  Message:
                    Expected 6 to equal '[object Object]1'.
                

                我的嘗試:

                items.count().then(function(count) {
                  startCount = count;
                  //console.log(startCount) --> "6" Perfect!
                });
                

                但是最后得到了同樣的結(jié)果……我不能把expect放到then里面,我也想過.

                But got the same result at the end... I can't put the expect into the then, I thought about that too.

                • 我搜索了 Protractor GitHub 存儲(chǔ)庫(kù)問題、StackOverflow 和 Google AngularJs 組.

                附錄:

                console.log(startCount) 輸出:

                { then: [Function: then],
                  cancel: [Function: cancel],
                  isPending: [Function: isPending] }
                

                我本可以編寫 .toEqual(6),但我不想在每次需要更改應(yīng)用啟動(dòng)狀態(tài)時(shí)都重寫測(cè)試.

                I could have written .toEqual(6) but I don't want to rewrite my test each time I need to change my app startup state.

                有什么想法嗎?提前致謝!!

                Any idea? Thanks in advance!!

                推薦答案

                你需要先解析promise,然后進(jìn)行斷言.

                You need to resolve the promise and then do the assertion.

                Protractor 將解析你傳遞給 expect() 的 Promise,但它不能在 Promise 中添加數(shù)字.你需要先解決promise的值:

                Protractor will resolve the promise that you pass to expect(), but it cannot add a number to a promise. You need to resolve the value of the promise first:

                beforeEach(function() {
                  ...
                  items.count().then(function(originalCount) {
                    startCount = originalCount;
                  });
                });
                
                it('should display a new item in list', function() {
                  ...
                  expect(items.count()).toEqual(startCount+1);
                });
                

                這篇關(guān)于如何使用量角器在 e2e 測(cè)試中預(yù)期元素的動(dòng)態(tài)計(jì)數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)

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

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

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

                            <tbody id='svXjp'></tbody>
                          <tfoot id='svXjp'></tfoot>
                        1. <legend id='svXjp'><style id='svXjp'><dir id='svXjp'><q id='svXjp'></q></dir></style></legend>
                        2. 主站蜘蛛池模板: 亚洲精品在线观看视频 | 国产视频精品区 | 干干干日日日 | 欧美视频在线播放 | 一区在线观看 | 国产一区精品在线 | 欧美国产日本一区 | 一区二区伦理电影 | 国产精品视频一二三 | 男人av在线播放 | 日本中文在线 | 欧美激情视频一区二区三区在线播放 | 人人人人干 | 一区二区三区四区在线免费观看 | 亚洲av一级毛片 | 久久久久久国产 | 欧美日韩国产在线 | 中文字幕亚洲一区二区va在线 | 亚洲一区二区三区免费在线观看 | 久久久国产一区二区三区 | 久久久九九 | 成人一区二区三区 | 日本一区二区高清不卡 | 天堂成人国产精品一区 | 亚洲免费网 | 久久综合久久久 | 日韩at| 一区二区三区四区在线免费观看 | 国产在线视频三区 | 玖玖精品视频 | 91久久久久久久久久久久久 | 国产精品一级 | 日韩一区二区av | 奇米久久 | 人人人艹| 亚洲福利视频网 | 中文字幕av一区 | 久久精品一 | 中文字幕国产 | 在线欧美 | 中文字幕不卡在线观看 |