量角器在中继器内查找元素 [英] Protractor find element inside a repeater
本文介绍了量角器在中继器内查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的标记
<tr ng-repeat="post in posts">
<td ng-click="activePost(post)" class="title">{{post.title}}</td>
<td><button class="btn btn-danger" ng-click="delete(post)">Delete</button>
</td>
</tr>
我正在尝试使用 title
类获取元素.
I'm trying to get the element with the title
class.
我用来访问中继器的代码是:
The code I use to access the repeater is:
postsList = element.all(by.repeater('post in posts'));
有没有办法通过在 jQuery 中执行以下操作来获取元素:
Is there a way to get the element by doing something like the following in jQuery:
var titleText = $("tr:first").find(".title").text();
有没有办法用量角器做类似的事情?
Is there a way of doing something similar to this with protractor?
推荐答案
这应该适用于您的示例:
this should work for your example:
element.all(by.repeater('post in posts')).then(function(posts) {
var titleElement = posts[0].element(by.className('title'));
expect(titleElement.getText()).toEqual('YourEnteredTitle');
});
这篇关于量角器在中继器内查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文