angularjs - Custom class or attribute in E2E testing -
having pretty complex angular application many pages (states) , conditional sections creates lot of test scenarios need perform e2e tests. i'm tired of nested selectors 'div.somecomponent > ul:nth-child(2) > ... ' , on using bem namings (especially when app evolving , it's easy spoil tests little change of html structure).
the question is, guys opt creating dummy (empty) classes or data-* attrs simplify protractor (or groovy) selector @ expense of loosing semantics? what's alternative?
to avoid changing element definitions every time developers change css , avoid using long css strings select elements, can try referring them other means (id, classname, model, etc.). see https://github.com/angular/protractor/blob/master/docs/locators.md examples.
my personal favorite use element(by.css('[ng-click="executesomeaction()"]')) not change application updates. works other directives well.
as testing applications high volume of pages , elements, it's nice define elements in class(es) , call them in test spec needed. reduces code in specs , makes them easier read. may want create separate file actions/functions tests perform.
hope helps answer questions.
Comments
Post a Comment