我需要根据点击次数来检查 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);
});
答案 0 :(得分:0)
对于量角器,您可以使用here中记载的getAttribute
。 getText()
返回元素内部的文本,而不返回元素属性。
您可以这样做
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;
});
希望有帮助...