I am currently testing a website that is built as a single page application using Angular.
Due to the nature of this architecture, much of the DOM is loaded in advance and hidden until needed. Depending on user actions, certain elements are displayed while others remain hidden. Protractor interprets all elements, whether visible or hidden, as part of the overall DOM structure. For example, if I try to locate an element by its id:
this.usernameTextbox = element(by.id('username'));
Protractor recognizes multiple elements with the same id - one visible due to ng-show
and the other hidden because of ng-hide
.
My question is, is there a way for Protractor to only identify elements that are not hidden?