用e2e端到端的测试时,发现用expect(repeater('.phones li', 'Phone List').column('phone.images'))没法得到值,写了一个方法来获取
1,json片断
"images": [ "img/phones/nexus-s.0.jpg", "img/phones/nexus-s.1.jpg", "img/phones/nexus-s.2.jpg", "img/phones/nexus-s.3.jpg" ], "name": "Nexus S",
2,repeater读取测试
expect(repeater('.phones li', 'Phone List').column('phone.name')). toEqual(["Nexus S","Dell Venue"]); //这样就可以的 expect(repeater('.phone-thumbs img', 'Phone List').column('phone.images')). toEqual(["Nexus S","Dell Venue"]); //这样就不可以了
我测试了很多种方法,发现读取的都是[ ]。
3,用element结合query可以读取
it('should load mock widgets into correct order, by seq', function () { var promise = element('.phone-thumbs img').query(function (elements, done) { var seq = []; elements.each(function () { seq.push(angular.element(this).attr('src')); }); done(null, seq); }); expect(promise).toEqual([ "img/phones/nexus-s.0.jpg", "img/phones/nexus-s.1.jpg", "img/phones/nexus-s.2.jpg", "img/phones/nexus-s.3.jpg" ]); });
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/jsjquery/1591.html