속성 중 하나의 텍스트로 각도기의 ng-repeat 내부에 특정 요소를 찾고 있습니다 (색인은 변경 될 수 있음).
HTML
<div ng-repeat="item in items">
<span class="item-name">
{{item.name}}
</span>
<span class="item-other">
{{item.other}}
</span>
</div>
내가 원하는 인덱스 (예 : 2)를 안다면 다음과 같이 할 수 있음을 이해합니다.
element.all(by.repeater('item in items')).get(2).element(by.css('.item-name'));
그러나이 특정 경우에는 "apple"이라는 특정 텍스트 (item.name)가있는 'item in items'를 찾고 있습니다. 언급했듯이 인덱스는 매번 달라집니다. 이것에 대해 어떻게 생각하십니까?
@ bdf7kt의 제안 된 솔루션을 단순화하여이 문제를 해결할 수있었습니다.
element.all(by.repeater('item in items')).each(function(elem) {
elem.getText().then(function(text) {
if(text.indexOf('apple') != -1) {
//do something with elem
}
});
});
또한이 특정 솔루션은 내 사용 사례에는 작동하지 않지만 다른 사람들에게는 작동합니다.
var item = element(by.cssContainingText('.item-name', 'apple'));
//do something with item
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다