Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

402
Visualizações
Cypress click on an nth image in a table with specifc src

I have a list of items in the table, each item has an image , active (blue) and not active (black), how do I make this query for cypress.

This is the image of the table list : enter image description here

Then this is the html code for the table : enter image description here

When expanded the image is below, it has a src path of /static/images/icon_profile.png enter image description here

My current test is like this :

it('Should create a legal form of a Customer profile', ()=>{
    cy.get('th').eq(50).find('img').should('have.attr', 'src', '/static/images/icon_profile.png').first().click()
  })

But when I ran it I get this error :

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can do it more easily by combining selectors

cy.get('tr img[src="/static/images/icon_profile.png"]')
  .first()
  .parent('a')  // click the link not the img
  .click()

To confirm you have the right index when using .eq(50) run

cy.get('tr img[src="/static/images/icon_profile.png"]')
  .first()
  .parent('tr')
  .invoke('index')  // which row is it?
  .log()
about 4 years ago · Juan Pablo Isaza Relatório

0

You can do something like this

cy.get('tr').each(($ele) => {
  if ($ele.attr('src') == '/static/images/icon_profile.png') {
    cy.wrap($ele).parent('a').click()
  }
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda