Anu*_*apu 0 testing jasmine protractor
我正在写量角器测试用例.我想点击编辑按钮.当我检查id它时,找不到它.
码:
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Code</th>
<th>Start Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="batch in batches.list">
<td><a ui-sref="root.courses.detail.batches.assessments({ batch_id: batch.id,assessment_status: 'published'})">BID00{{batch.id}}</a></td>
<td>{{batch.start_date}}</td>
<td>
<button id="edit" type="button" class="btn btn-default btn-sm" tooltip-placement="top" tooltip="Edit" ng-controller="batchesCtrl" ng-click="edit_batch(batch.id)"><i class="glyphicon glyphicon-edit"></i></button>
<button type="button" id="delete(batch.id)" class="btn btn-danger btn-sm" tooltip-placement="top" tooltip="Delete" ng-click="remove_batch(1, batch.id)" confirmation-needed="Do you really want to delete this batch?"><i class="glyphicon glyphicon-trash" ></i></button>
</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我怎样才能使它工作?
小智 5
您的示例中存在一些问题.在html中,ID在页面上应该是唯一的.所以你不能在重复的元素中使用id.
你有几个选择.您可以通过其中一个样式来解决按钮,而另一个按钮则没有
element(by.repeater('batch in batches.list').row(0)).element(by.css('button.btn-default')).click();
Run Code Online (Sandbox Code Playgroud)
您也可以指定您想要的第一个按钮
element(by.repeater('batch in batches.list').row(0)).element(by.css('button:first-of-type')).click();
Run Code Online (Sandbox Code Playgroud)
或者,您也可以仅使用css来处理元素.有时这比中继器更容易维护:
element(by.css('tr:first-of-type > td:last-child > button:first-of-type')).click();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3862 次 |
| 最近记录: |