I have a bunch of Protractor tests for for e2e of a web application. There are a lot of input boxes , and a majority of them have ng-reflect-name
attribute generated due to the underlying Angular4 code. Here is an example HTML snippet
<input _ngcontent-c6="" class="input ng-untouched ng-pristine ng-invalid ui-inputtext
ui-corner-all ui-state-default ui-widget" formcontrolname="email" pinputtext=""
placeholder="Enter Email Address" spellcheck="false" type="text" ng-reflect-name="email">
My issue is regarding the use of locator in this. If I use this code for this specific input box -
element(by.css('[formcontrolname='email']'))
and perform any sendKeys()
operation, it works out completely fine.
However, if I use this locator
element(by.css('[ng-reflect-name="email"]'))
my tests run for the successfully for the first time, but errors out giving a NoSuchElementException
for the subsequent runs. I have searched on SO and the Angular docs, but I can't seem to explain why this happens. If anyone has faced this issue before, can you explain what is happening here?