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

255
Vistas
How to handle waitForSelector when selector is not found

I'm trying to wait for a selector. When the selector is not available, which can happen I would expect to catch that error in the .catch() and be able to proceed with my program. Instead I get the UnhandledPromiseRejectionWarning error.

How can I write a program that can handle selectors that is not found or times out?

Code

await page.waitForSelector('#step3 > div > div > div > div.time-selection-wrapper > div.v-card.v-sheet.theme--light > div > div > div.v-picker__title.primary-color > div > div.v-picker__title__btn.v-date-picker-title_custom1.v-picker__title__btn--active > div', {timeout: 5000})
    .then(async () => {
        console.log("Entered THEN")
    })
    .catch((e) => {
        if (e instanceof puppeteer.errors.TimeoutError) {
            console.log("Timeout")
        }
    })

Output

Timeout (node:9540) UnhandledPromiseRejectionWarning: Error: Node is either not clickable or not an HTMLElement at ElementHandle.clickablePoint (/home/john/git/myproject/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:412:19) (node:9540) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:9540) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

about 4 years ago · Juan Pablo Isaza
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