我正在编写一个端到端的测试,使用。我正在用量角器进行测试。我有以下标记
<ul class="phone-thumbs">
<li ng-repeat="img in phone.images">
<img ng-src="{{img}}">
</li>
</ul>我想测试一下,对于一个特定的页面实例,我有四个这样的图像。到目前为止,我的情况如下
describe('Phone detail view', function() {
beforeEach(function() {
browser.get('app/index.html#/phones/nexus-s');
});
it('should display four thumbnails on the nexus-s page', function() {
expect(element(by.css('.phone-thumbs li img')).length()).toBe(4);
});
});问题是我说错话了
TypeError: Object #<Object> has no method 'length'我哪里出问题了?
发布于 2015-03-31 13:48:15
这个问题是https://docs.angularjs.org/tutorial/step_08的AngularJS教程中实验部分的一部分。
我就是这样解决的。我采用了不同的方式来计算渲染的图像,而不是直接测试中继器/模型。
it('should display four thumbnails of the nexus-s', function() {
var imgsCount = element.all(by.css('.phone-thumbs li img')).count();
expect(imgsCount).toBe(4);
});发布于 2014-05-10 16:42:37
对任何需要知道这一点的人来说。我就是这么做的。
it('should display four thumbnails on the nexus-s page', function() {
var images = element.all(by.repeater('img in phone.images')).count();
expect(images).toBe(4);
});https://stackoverflow.com/questions/23583408
复制相似问题