简体   繁体   中英

how to expect if item is present in the list

How can I compare a String with a List of 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');
});

You can actually make the expectation in one go with toContain() matcher:

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

Note that there is no need to resolve the promise with then() - expect() is capable of understanding if there is a promise passed in and resolving it under-the-hood.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM