【问题标题】:how to expect if item is present in the list如何期待项目是否存在于列表中
【发布时间】:2016-09-22 20:39:27
【问题描述】:

如何将字符串与ng-repeat 的列表进行比较:

this.TenantList = element.all(by.repeater("tenant in tenantList"));

TenantList.getAttribute('aria-label').then(function(list) {
    //label contains 10 items and I want to see if this list contains 'Test'
    expect(list).toMatch('Test');
});

【问题讨论】:

    标签: javascript testing jasmine protractor


    【解决方案1】:

    您实际上可以使用toContain() matcher 一次性完成预期:

    expect(TenantList.getAttribute('aria-label')).toContain('Test');
    

    请注意,无需使用 then() 解决承诺 - expect() 能够了解是否传入了承诺并在后台解决它。

    【讨论】:

    • 感谢@alecxe 它提供了帮助。
    猜你喜欢
    • 2014-05-07
    • 1970-01-01
    • 2013-05-07
    • 2019-12-18
    • 1970-01-01
    • 2013-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多