Get The Index Of An Element Using jQuery Method
In this video, we find an element, and then confirm its index among its siblings by invoking the jQuery method index() cy.get('#carousel li.active') // call jQuery index() method // to yield the index of the active LI item .invoke('index') .should('equal', 2) // if you want to work with the index, // yield it to the next command .then(function (index) { cy.log(`index is **${index}**`) }) Find this example and many more at https://glebbahmutov.com/cypress-examples
In this video, we find an element, and then confirm its index among its siblings by invoking the jQuery method index() cy.get('#carousel li.active') // call jQuery index() method // to yield the index of the active LI item .invoke('index') .should('equal', 2) // if you want to work with the index, // yield it to the next command .then(function (index) { cy.log(`index is **${index}**`) }) Find this example and many more at https://glebbahmutov.com/cypress-examples