Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Cómo verificar que la imagen es visible/existe en el front-end usando la etiqueta <img src> o <a href>

¿Alguien sabe cómo puedo verificar si existe una imagen usando su <a href> o <img src> ? Solo puedo verificar por su clase como:

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

pero quiero saber cómo verificar con la etiqueta img src o href. gracias

HTML completo:

 <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>

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Una prueba más explícita podría seleccionar href y .find() the img, para evitar el problema de devolver varias imágenes.

 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 Report

0

Si entiendo bien, usted está buscando

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

Similarmente

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

donde debe agregar el texto apropiado en lugar de ...

Por supuesto, sigue con .should('be.visible') .

Si desea utilizar una coincidencia parcial, puede utilizar

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

0

Si desea afirmar la imagen con el nombre de la imagen, puede hacer algo como:

 cy.get('img').invoke('attr', 'src').should('include', 'bottle.png')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!