加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 删除NG重复量角器中的记录

发布时间:2020-12-17 17:24:50 所属栏目:安全 来源:网络整理
导读:所以我用量角器和角度进行e2e测试, 我的第一个测试是在列表中添加一个元素, 现在我正试图删除它,而我却遇到了麻烦 所以这就是我需要做的: 找到我要删除的记录的名称 单击该行的垃圾桶图标并将其删除 在出现的弹出窗口中按“确定” 尝试尽可能避免使用By.css
所以我用量角器和角度进行e2e测试,
我的第一个测试是在列表中添加一个元素,
现在我正试图删除它,而我却遇到了麻烦

所以这就是我需要做的:

>找到我要删除的记录的名称
>单击该行的垃圾桶图标并将其删除
>在出现的弹出窗口中按“确定”
>尝试尽可能避免使用By.css并更喜欢与angular(byBinding,model等)相关的所有内容.这是因为应用程序的这一部分最终会改变,因此我将不得不重做所有这些情况.

HTML:

<div class="list-group-item ng-scope" ng-repeat="item in teamList">
    <span class="glyphicon glyphicon-user"></span>
    <span ng-bind="item.name" class="memberName ng-binding">nuevo Team</span>
    <a ng-click="editTeam(item._id)" class="hand-cursor">
        <span class="glyphicon glyphicon-edit memberRemoveBotton"></span>
    </a>
    <a ng-confirm-click="Would you like to delete this item?" confirmed-click="deleteTeam(item._id)" class="hand-cursor">
        <span class="glyphicon glyphicon-trash memberRemoveBotton"></span>
    </a>
</div>

JS:

describe('Testing delete Item',function() {
        it('Should delete the Item that just got Inserted',function() {
            element(by.css('a[href="#!/item-create"]')).click(); //Opens up the Item dashBoard
            element.all(by.repeater('item in itemList')).then(function(table) {
                table.element(by.binding('item.name')).each(function(names) {
                    console.log('the names',names.getText());//I'm trying to find the name of the item that just got inserted
                    // is there like a nested chaining of elements in here ??
                });         
            });
        });
});

任何关于如何解决这个问题的提示都表示赞赏

解决方法

describe('Testing delete Item',function() {
  it('Should delete the Item that just got Inserted',function() {
    // Assume you know the name of the item you want to delete.
    var nameToDelete = 'some name';

    // Get the row that has the name by using filter.
    element.all(by.repeater('item in itemList')).filter(function(row){
      return row.element(by.css('.memberName')).getText().then(function(name){
        return name === nameToDelete; 
      });
    })
    // Now you should have one row.
    .get(0)
    // Get the row and click find the remove button.
    .element(by.css('.memberRemoveBotton'))
    .click();

    // Make sure it was deleted.
    var names = $$('.list-group-item .memberName').getText();
    expect(names).not.toContain(nameToDelete);
  });
});

如果有效,请告诉我.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读