What is the best way to check for values in an E2E test?

30 views
Skip to first unread message

Chris

unread,
Feb 12, 2012, 7:52:05 PM2/12/12
to AngularJS
I am working more with Angular and starting to setup larger E2E tests.
As I do this, it feels like there must be a more Angular way than the
approach that I'm taking. I currently have to go back and add a unique
ID to any HTML element that I want to check. This leads to a lot of
unique IDs that are only there for E2E testing purposes. I understand
that this might be necessary, but if there is another best practice,
I'd like to consider it.

Is there a way to do more generic look-ups such as:
expect(html.body.nth-child(1).nth-child(4).text()).toBe('Testing');

Are there any other recommendations to adding simple tests to an
existing page without having to change the page under test?

Thanks,
Chris

Vojta Jina

unread,
Feb 13, 2012, 1:10:55 AM2/13/12
to ang...@googlegroups.com
You don't have to add unique ids. Any jQuery selector can be used...

E.g.
expect(element('div.class span').text()).toEqual('something');

V.

Reply all
Reply to author
Forward
0 new messages