[Vuejs]-Protractor – "More than one element found for locator" when using by.id

0👍

Try printing the source code at this time and you will fine out how many elements are in DOM with similar id

0👍

Try this one

element(by.css('input[type = "text"]'))

0👍

Finally found the answer after frustrating 10 hours of digging through.

  1. Set “:name” for . Don’t set “:id”. Like this :name=”currentField.id”
  2. In Protractor code, use the name to fetch the element. Like this –
    var inputtxt=element(by.css(“input[name=’txt1′]”));

  3. Don’t use getText(), it behaves weird, return empty. Use inputtxt.getAttribute(‘value’)) where “value” is the underlying field assigned to “v-model”

  4. IMPORTANT – allow the page to load fully by setting browser.sleep(x ms). Else the element gets retrieved multiple times, protractor throws a warning “More than one element is located….”

Leave a comment