Reputation: 341
I basically want to run the below function but it gives me an error. Please give me a hand if you can. Thank you
cy.get('[data-auction-type-text=Regular]').should('be.visible')
.each(($el,index) => {
if(index==0){
$el.then.click()
}
Upvotes: 1
Views: 718
Reputation:
You can use click()
on the $el
cy.get('[data-auction-type-text=Regular]').should('be.visible')
.each(($el,index) => {
if (index === 0) {
$el.click()
}
or without .each()
cy.get('[data-auction-type-text=Regular]').should('be.visible')
.eq(0) // equivalent to if(index==0)
.click()
Upvotes: 3
Reputation: 18650
Instead of $el.then.click()
you have to use -
cy.wrap($ele).click()
$ele
is a jquery wrapped element. In order to use cypress commands, we have to use wrap.
Upvotes: 0