Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda