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

160
Vistas
How to verify Image is visible/exists on front end using <img src> or <a href> tag

Does anyone know how I can verify if an image exists using its <a href> or <img src>? I can only verify by its class such as:

it('Verifying vertical product', () => {
    cy.get('.stage --vertical').should('be.visible')
})

but I want to know how to verify with img src or href tag. thank you

Full HTML:

<a href="haigclub.diageoplatform.com/en/our-whisky/haig-club-clubman"> 
  <img style="margin: auto; display: block;" class="stage__image" 
    src="haigclub.diageoplatform.com/user/themes/haig/images/bottle.png"> 
</a>

enter image description here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

A more explicit test might select href and .find() the img, to avoid the problem of returning multiple images.

cy.get('a[href^="haig-club-clubman"]')
  .find('img')                             // find inside previous selector (a[href])
  .should('have.attr', 'src')
  .and('include', 'bottle.png')            // explicit test of src attribute
about 4 years ago · Juan Pablo Isaza Denunciar

0

If I understand correctly, you are looking for

cy.get('a[href="..."]')

Similarly

cy.get('img[src="..."]')

where you should add the appropriate text instead of ...

Of course, follow with .should('be.visible').

If you want to use a partial match, you can use

cy.get('img[src$="bottle.png"]')  // NOTE src$= 
about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want to assert the image with the image name you can do something like:

cy.get('img').invoke('attr', 'src').should('include', 'bottle.png')
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