2
我正在开发我的angular e2e测试项目。我将下面的html作为我的ng-repeat的一部分生成,并且不包含任何id,我想选择与标题Topic - xyz一起使用的第二个元素,然后单击它是兄弟的子元素的按钮。我怎样才能做到这一点。从元素数组中选择第n个元素jquery
<div class="row ng-scope" ng-repeat="post in posts">
<div class="col-md-7">
<h4 class="ng-binding">Topic - ABC</h4>
<div class="text-right">
<button class="btn btn-none btn-sm" ng-click="posts.newPost()">
Create Post
</button>
</div>
</div>
</div>
<div class="row ng-scope" ng-repeat="post in posts">
<div class="col-md-7">
<h4 class="ng-binding">Topic - XYZ</h4>
<div class="text-right">
<button class="btn btn-none btn-sm" ng-click="posts.newPost()">
Create Post
</button>
</div>
</div>
</div>
<div class="row ng-scope" ng-repeat="post in posts">
<div class="col-md-7">
<h4 class="ng-binding">Topic - EFG</h4>
<div class="text-right">
<button class="btn btn-none btn-sm" ng-click="posts.newPost()">
Create Post
</button>
</div>
</div>
</div>
这是我一直在努力,到目前为止,这是不工作
var button = $$(by.repeater('post in posts')).get(1).$(by.css('[ng-click="posts.newPost()"]'))
button.click(); // click is not showing up
谢谢alecxe,我已经使用了最后的解决方案,因为我已经得到了直到var post = element.all(by.repeater('post in posts'))。get(1);你的解决方案就像魅力一样 –