问题
原文链接:https://www.f2er.com/angularjs/240415.html调用转发器(‘#myTable tr’,’Rows’).count();返回Future,而不是整数.我需要获取整数值,以便我可以确认在表中添加了一行.
码
it('should add a new user when save button is clicked',function() { showModal(); //here I'm trynig to store the row count of my table into a local variable. //a future is returned who's 'value' field is undefined. var memberCount = repeater('#memberTable tr','Member Rows').count(); //this outputs 'undefined' console.log(memberCount.value); input('editedMember.name').enter('John'); input('editedMember.grade').enter(5); input('editedMember.ladderPosition').enter(3); element('#saveMemberButton').click(); sleep(1); expect(element(modalId).css('display')).toBe('none'); //here is where I want to do the comparison against the above stored memberCount expect(repeater('#memberTable tr','Member Rows').count()).toBe(memberCount.value + 1); });
测试结果
Chrome 25.0 e2e should add a new user when save button is clicked Failed expect repeater 'Member Rows ( #memberTable tr )' count toBe null /Users/jgordon/learning/chessClub/web-app/test/e2e/scenarios.js:45:3: expected null but was 6 Chrome 25.0: Executed 2 of 2 (1 Failed) (1 min 4.117 secs / 1 min 3.773 secs)