When selecting elements by id using cy.get() and then typing into them using .type() the wrong element is typed into. This happens intermittently in a number of tests I have written. The get seems to select the correct element, but then the type inputs in a different one.
Example:
element correctly selected
value entered into wrong element
Ive tried a number of things here. cy.get('#elementid').clear().type('new text') was how I used to do this, but changed to cy.get('#elementid').type('{selectall}new text'). The new method causes this issue to happen far less often, but it still does.
The complete command used in the example screenshots is using a loop to build the element IDs, but this issue also appears when selecting elements without a loop.
Cypress.Commands.add('new_supplier_preisanfrage', (customerFullName, discount, priceList) => {
cy.open_supplier_preisanfrage_dialog(customerFullName)
cy.get('#1917240871_' + (priceList.length - 1) + '_price').should('exist').then(() => {
for (var i = 0; i < priceList.length; i++) {
var price = priceList[i]
cy.get('#1917240871_' + i + '_price').type('{selectall}' + price)
cy.get('#1917240871_' + i + '_discount').type('{selectall}' + discount)
}
}).then(() => {
cy.get('#price-inquiry-edit-save-btn').click()
})
})
You can see here that I also tried using .then() to wait until all the fields have been loaded into the DOM.
So, How do I debug this further? Is this a known issue? What am I doing wrong here?