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

291
Vistas
PLAYWRIGHT testing - How to skip to the next action if a click on a button is not possible (is not present)?

as anticipated in the question, I'd like to know if is possible to attempt a click action on a button, but if it's not in the page then the test skip that action (without being stucked or throwing an error) and continue to the next one. To be more specific, I have a modal where I can add rows to a table, but what I'd like to do is to add a new row only if a given button in the modal is not present, while if it's present the action would be to press first on that button and then proceeding to add a new row.

I ask you if it's possible because I'd like to avoid conditional statements during the test. Just let me know, thank you in advance :)

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

0

You can check if the element is present then do something if not then do nothing or something else.

 const modal = page.locator('modal-selector');
    
 if (await modal.isVisible()) {
   // do thing
 } else {
   // do another thing
 }

about 4 years ago · Juan Pablo Isaza Denunciar

0

const locator = page.locator("some selector");
if (locator.count() > 0) {
  // found locator, do something
} else {
  // not found, do something else
}
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