cy.first() do in Cypress?cy.first() selects the first element from a set of matched elements in the DOM.
Think of it like picking the first apple from a basket.
cy.last() differ from cy.first()?cy.last() selects the last element from a set of matched elements, while cy.first() selects the first.
Imagine picking the last cookie from a jar instead of the first.
cy.eq(index).cy.eq(index) selects the element at the given zero-based index from matched elements.
It's like choosing the 3rd book on a shelf by counting from the start.
cy.eq()?cy.eq() uses zero-based indexing, meaning the first element is at index 0.
So, cy.eq(0) is the same as cy.first().
cy.first(), cy.last(), or cy.eq() in tests?They help you pick a specific element from many, making tests precise and reliable.
Like choosing the exact item you want to check in a list.
cy.first() select?cy.first() picks the first element only.
cy.last() selects the last element.
cy.eq(2) select?Index 2 means the third element (zero-based counting).
Index 1 is the second element in zero-based indexing.
cy.eq(0)?cy.first() selects the first element, same as cy.eq(0).
cy.first(), cy.last(), and cy.eq() help in selecting elements during testing.cy.eq().