Angularjs 从元素数组jquery中选择第n个元素

Angularjs 从元素数组jquery中选择第n个元素,angularjs,protractor,Angularjs,Protractor,我正在做我的角e2e测试项目。我已经生成了以下html作为我的ng repeat的一部分,没有任何id,我想选择标题为Topic-xyz的第二个元素,然后单击它的兄弟元素的子元素按钮。我该怎么做呢 <div class="row ng-scope" ng-repeat="post in posts"> <div class="col-md-7"> <h4 class="ng-binding">Topic - ABC</h4>

我正在做我的角e2e测试项目。我已经生成了以下html作为我的ng repeat的一部分,没有任何id,我想选择标题为Topic-xyz的第二个元素,然后单击它的兄弟元素的子元素按钮。我该怎么做呢

<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>
$$(by.repeater('post in posts'))
$(by.css('[ng click=“posts.newPost()”])
-使用
by.repeater()
by.css()
定位器的语法不正确
$
元素.all(by.css())
的快捷方式,不应用于“repeater”定位器。如果使用
$()
,则无需将选择器包装到
by.css()


如果要按主题名称筛选中继器元素,可以使用
.filter()


还可以查看使用是否也能正常工作(稍微干净一点):


感谢alecxe,我使用了上一个解决方案,因为我已经得到了till var post=element.all(by.repeater('post in posts')).get(1);你的解决方案很有魅力。
var button = $$(by.repeater('post in posts')).get(1).$(by.css('[ng-click="posts.newPost()"]'))

button.click(); // click is not showing up
var button = element.all(by.repeater('post in posts')).get(1).$('[ng-click*=newPost]');
button.click();
var button = element.all(by.repeater('post in posts')).filter(function (post) {
    return post.$("h4").getText().then(function (postTitle) {
        return postTitle === "Topic - XYZ";
    });
}).get(1).$('[ng-click*=newPost]');
button.click();
var post = element.all(by.repeater('post in posts')).get(1);

var button = post.element(by.buttonText("Create Post"));
button.click();