Testing 量角器通过中继器点击元素
我正试图通过repeater从列表中单击第一个元素 我的HTML看起来像:Testing 量角器通过中继器点击元素,testing,protractor,end-to-end,Testing,Protractor,End To End,我正试图通过repeater从列表中单击第一个元素 我的HTML看起来像: <ul class="list-unstyled" ng-show="axCarSearch.found.length"> <!-- ngRepeat: car in axCarSearch.found --><li ng-repeat="car in axCarSearch.found" viewport-check="$index==axCarSe
<ul class="list-unstyled" ng-show="axCarSearch.found.length">
<!-- ngRepeat: car in axCarSearch.found --><li ng-repeat="car in axCarSearch.found" viewport-check="$index==axCarSearch.current" class="ng-scope">
<a class="clearfix current" ng-mousedown="axCarSearch.select(car)" ng-class="{current: $index==axCarSearch.current}">
<!-- ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">VW</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd --><strong ng-repeat-start="m in car.match track by $index" ng-if="$odd" class="text-primary ng-binding ng-scope" ng-bind="m">Passat</strong><!-- end ngIf: $odd -->
<!-- ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">05/07-10/10 (3C)</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index -->
<!-- ngIf: !car.match -->
<small class="pull-right text-muted ng-binding">Typ</small>
</a>
</li><!-- end ngRepeat: car in axCarSearch.found --><li ng-repeat="car in axCarSearch.found" viewport-check="$index==axCarSearch.current" class="ng-scope">
<a class="clearfix" ng-mousedown="axCarSearch.select(car)" ng-class="{current: $index==axCarSearch.current}">
<!-- ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">VW</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd --><strong ng-repeat-start="m in car.match track by $index" ng-if="$odd" class="text-primary ng-binding ng-scope" ng-bind="m">Passat</strong><!-- end ngIf: $odd -->
<!-- ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">10/00-05/05 (3B3/3B6)</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index -->
<!-- ngIf: !car.match -->
<small class="pull-right text-muted ng-binding">Typ</small>
</a>
</li><!-- end ngRepeat: car in axCarSearch.found --><li ng-repeat="car in axCarSearch.found" viewport-check="$index==axCarSearch.current" class="ng-scope">
<a class="clearfix" ng-mousedown="axCarSearch.select(car)" ng-class="{current: $index==axCarSearch.current}">
<!-- ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">VW</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd --><strong ng-repeat-start="m in car.match track by $index" ng-if="$odd" class="text-primary ng-binding ng-scope" ng-bind="m">Passat</strong><!-- end ngIf: $odd -->
<!-- ngIf: $even --><!-- end ngRepeat: m in car.match track by $index --><!-- ngIf: $odd -->
<!-- ngIf: $even --><span ng-repeat-end="" ng-if="$even" ng-bind="m" class="ng-binding ng-scope">10/96-09/00 (3B2/3B5)</span><!-- end ngIf: $even --><!-- end ngRepeat: m in car.match track by $index -->
<!-- ngIf: !car.match -->
<small class="pull-right text-muted ng-binding">Typ</small>
</a>
</li>
</ul>
不幸的是,我得到了一个错误:
使用定位器未找到元素:by.repeater(车入
axCarSearch.find“).row(“0”)
有没有人能帮我找到一种方法来点击这个
请?相反,试着先调用元素数组索引:
var rows = element.all(by.repeater("car in axCarSearch.found"));
rows.first().element(by.tagName("a")).click();
能否尝试添加以下元素.all(by.repeater('car in axCarSearch.found')).count()。然后(function(count){console.log(count);})代码>,运行测试并查看控制台上的输出是什么?谢谢。Hi@alecxe它返回正确数量的选项,在本例中,它是对答案alecxe的3次感谢,就像这是有可能调用其他东西,然后是“first”和“last”,我找到了一种方法,通过:element(by.css(“[viewport check=“$index==axCarSearch.current”])单击第一个选项。单击();这是一个特定的页面,不是一个好的解决方案。@Andurit是的,您可以使用get(index)
而不是first()
和last()
。我同意你使用的定位器不太可靠,可读性也不好。通过.tagName()显示的是否有效?谢谢。效果很好,只是efect弹出窗口出现了一些问题,所以不得不添加短睡眠浏览器。睡眠(1000);谢谢你的建议
var rows = element.all(by.repeater("car in axCarSearch.found"));
rows.first().element(by.tagName("a")).click();