Reputation: 797
Jasmine and Karma, latest version, testing an AngularJS instance.
I tried
expect(element('a.topic-heading-link-10')).toBeDefined();
but it responds
expect undefined toBeDefined undefined
http://example.com/test/e2e/scenarios.js:16:7
expected undefined but was undefined
Not doesn't look very good. What is a better way to test the presence of a CSS selector?
Upvotes: 3
Views: 4162
Reputation: 2482
You can use count
to ensure your "look up" found something. For instance:
expect(element('a.topic-heading-link-10').count()).toEqual(1);
If the element doesn't exists or it doesn't have that specific class, count()
will equal 0.
Upvotes: 6