在HTML页面中我有:
In an html page I have:
<ul class="phones">
<li ng-repeat="phone in phones | filter:query | orderBy: orderProp">
{{phone.name}} - {{phone.age}}
<p>{{phone.snippet}}</p>
</li>
</ul>
在一个端到端的测试我已经(正在返回数组中的两个元素):
In an e2e test I have (is returning two elements in the array):
var result= ptor.findElements(protractor.By.repeater('phone in phones').column('phone.name'));
result.then(function(arr) {
arr[0].getText().then(function(text) {
console.log("*** 1: "+ text);
});
arr[1].getText().then(function(text) {
console.log("*** 2: "+ text);
})
});
在控制台打印所有三列,phone.name,phone.age和phone.snippet。为什么选择不只是返回phone.name?
The console is printing all three columns, phone.name, phone.age, and phone.snippet. Why is the selector not just returning phone.name?
它实际上返回无论我在列表中的礼,纯文本或有约束力的。
Its actually returning whatever I have in the list "li", plain text or a binding.
推荐答案
这个例子试图查找与下面的战略要素(柱部分固定为每个评论)
The example tries to locate elements with the strategy below (column part is fixed as per comments):
protractor.By.repeater('phone in phones').column('name')
直放站部分里
元素相匹配,然后去找到 phone.name
元素(S)结合。它的包装元素恰好是同一里
。
Repeater part matches the li
element and then goes to find element(s) with phone.name
binding. It's wrapping element happens to be the same li
.
更改列部分 .column('片断')
收益 P
元素,因为 phone.snippet
绑定发现的内部。
Changing column part to .column('snippet')
returns p
elements because phone.snippet
binding is found inside of those.
相关的文档/例子在这里:的https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests
Relevant docs/examples here: https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests
相关推荐
最新文章