How to write locator for this highlighted input field element when ID and Class attribute are dynamic?
Also for this button
How to write locator for this highlighted input field element when ID and Class attribute are dynamic?
Also for this button
The "Course name" text is a notable feature of that block of HTML. Select it and use traversal commands to get to the <input>
cy.contains('span', 'Course name')
.next()
.find('input')
Alternatively, the placeholder text could be used (but it seems a bit generic)
cy.get('input[placeholder="Enter"]')
For the <button>
a similar tactic
cy.contains('p', 'Add new course')
.prev('button')
.click()