ZombiePie
ZombiePie

Reputation: 377

Click on button based on text in table

I need to click on the edit button of a certain text in a table.

For example the table row has the text abc i need to click on the icon-pencil of this particular row text

I have tried:

cy.contains('td', 'abc')
            .scrollIntoView()
            .siblings()
            cy.get('td div').within(() => {
                cy.get('.actions').and('have.class','icon-pencil').click()
                })

but it is not finding the class actions

This is the html:

enter image description here

Please let me know what is wrong. thank you

Upvotes: 0

Views: 124

Answers (1)

Alapan Das
Alapan Das

Reputation: 18624

You have to do something like this:

cy.contains('td', 'abc')
  .parent('tr')
  .within(() => {
    cy.get('i.icon-pencil').click()
  })

Upvotes: 1

Related Questions