Bootstrap   发布时间:2022-04-18  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了twitter-bootstrap – Angular e2e Testacular Test:如何辨别可见性?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如果在单击按钮时显示Bootstrap模式,是否有人成功测试过?

细节

我正在编写一个Testacular测试,用于检查单击按钮时是否显示Bootstrap模式.问题是对css(‘display’)的调用返回’none’,即使我可以看到窗口弹出并且可见.

我想知道是否有一些怪异的Bootstrap Modal会复制一个html块然后用不同的id显示.我当然希望不是!

场景

describe('e2e',function() {

  beforeEach(function() {
    browser().navigateTo('/chessClub/');
  });


  it('should display editor when add member button clicked',function() {
    expect(element('title').text()).toBe("Chess Club");

      expect(element('#mymodal').css('display')).toBe('none'); //as expected,it is none
              //click the button to show the modal
      element('#addMemberButton','Add Member Button').click();

              //this 2nd expect still return 'none'
      expect(element('#mymodal').css('display')).toBe('block');

  });

});

测试输出

Chrome 25.0 e2e should display editor when add member button clicked Failed
    expect element '#mymodal' get css 'display' toBe "block"
    /Users/jgordon/learning/chessClub/web-app/test/e2e/scenarios.js:17:4: expected "block" but was "none"

HTML

<!-- Modal -->
<div id="mymodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="mymodalLabel">{{editorLabel}}</h3>
    </div>
    <div class="modal-body">
        <form>
            <label>
                Name
            </label>
                <input type="text" ng-model="editedMember.name" placeholder="John Doe">
            <label>
                Grade
            </label>
                <input type="text" ng-model="editedMember.grade">
            <label>
                Ladder Position
            </label>
                <input type="text" ng-model="editedMember.ladderPosition">
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-priMary" ng-click="saveMember()">Save changes</button>
    </div>
</div>

解决方法

一种方法,然有点hacky是使用:visible选择器并计算有多少匹配

expect(element('#someElement:visible').count()).toBe(1);

Source

大佬总结

以上是大佬教程为你收集整理的twitter-bootstrap – Angular e2e Testacular Test:如何辨别可见性?全部内容,希望文章能够帮你解决twitter-bootstrap – Angular e2e Testacular Test:如何辨别可见性?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。