sonia sharma sonia sharma - 2 months ago 7
Javascript Question

How to check text is not present in the list

I want to check if the text is not present in the list.

this.TenantList = element.all(by.repeater("tenant in tenantList"));
expect(TenantList.getAttribute('aria-label'))not().toContain('Test');


I tried following but its failing :
is not a function


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

Answer

.not is not a function, the correct syntax is:

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