![](/img/trans.png)
[英]How do I get an element with `aria-hidden` true out of a bunch of elements that have the same attribute?
[英]In Protractor, how to check aria-hidden = "true" or "false"
我需要根据点击检查aria-hidden="true" 或 "false"
<tr ng-class="{'submitted' : (position.submitted) }" ng-repeat-
start="position in demandFactory.openings | orderBy:sortType:sortReverse">
<td><span ng-click="openDemand(position.demandID)"><span ng-show="position.demandID == demandFactory.selectedDemand">
<span class="glyphicon glyphicon-menu-down glyphicon-small" aria-hidden="true"></span>
</span>
<span ng-show="position.demandID != demandFactory.selectedDemand">
<span class="glyphicon glyphicon-menu-right glyphicon-small" aria-hidden="true"></span>
</span></span>
<span class="jobName"> {{ position.name }} </span>
</td>
<td>{{ position.demandID }}</td>
<td>{{ position.rotation }}</td>
<td>{{ position.headcount }}</td>
<td>{{ position.num }}</td>
<td>{{ position.approved }}</td>
</tr>
在测试用例中,我访问了该元素,但可以获取检查aria-hidden值。
var aPromiseOfRows = element.all(by.repeater('position in demandFactory.openings').row(0).column("position.name"));
aPromiseOfRows.getText().then(function(text) {
console.log(text);
});
使用量角器,您可以使用此处记录的getAttribute
。 getText()
返回元素内的文本,而不是元素属性。
你可以做这样的事情
get(index
thats documentation here) get(index
要测试的元素。expect()
获取属性伪代码:
var aPromiseOfRow = element.all(by.repeater('position in demandFactory.openings').get(0);
expect(aPromiseOfRow.getAttribute('aria-hidden')).toEqual('true');
如果您希望访问该值以供以后使用,请使用以下内容
var val;
aPromiseOfRow.getAttribute('aria-hidden').then(function(attrValue) {
val = attrValue;
});
希望有帮助...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.