如何获取Ember验收测试列表中的LAST元素



在编写验收测试时,有人知道如何选择列表中的LAST元素吗?我正在测试向列表中添加新记录的操作,并希望在测试中编辑/删除新创建的记录
我试着这样选择新创建的记录。。。。

let newRecordLink = find('div.parent-list .list-group-item').last();
click(newRecordLink);

哪种方式有效。它提取了最后一个元素,但它从我的测试中弹出,突然我出现在我试图测试的应用程序的实际页面上,而不是留在测试容器中。

这是相关的HBS代码:

<div class="list-group parent-list">
  {{#each model.owners as |item|}}
    {{#link-to 'client.members.edit-owner' item.id class="list-group-item" id=item.id}}
      <h4 class="list-group-item-heading">
        {{item.firstName}} {{item.lastName}}
      </h4>
    {{/link-to}}
  {{/each}}
</div>

您可以使用:last选择器(https://api.jquery.com/last-selector/)

click('div.parent-list .list-group-item:last')

如果它是一个成员数组,你可以使用.get('lastObject')

我也在努力解决这个问题,但我使用了:last of type而不是:last

相关内容

最新更新