我如何比较字符串和 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');
});
最佳答案
实际上,您可以使用 toContain()
匹配器一次完成期望:
expect(TenantList.getAttribute('aria-label')).toContain('Test');
请注意,无需使用 then()
来解析 promise - expect()
能够理解是否传入了 promise 并在下面解析它-引擎盖。
关于javascript - 如何期望列表中是否存在项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39648490/