Reputation: 37
I´m triyng to select an array, using cypress. I have this element "cy.get(".link.nav-link")[0]"
When I try to click on the element, cypress returned me: "Cannot read property 'click' of undefined"
Below I add my code
class Home {
get services() {
return cy.get(".link.nav-link")[0];
}
clickOnServices() {
this.services.click()
}
}
export default new Home();
Upvotes: -1
Views: 1571
Reputation: 18618
eq
gets A DOM element at a specific index in an array of elements.
Changing cy.get(".link.nav-link")[0]
to cy.get(".link.nav-link").eq(0)
should work.
Upvotes: 5