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

361
Vistas
Puppeteer, click only working within page.evaluate()?

This fails to click the element:

await page.click(
  "#trigger > ytcp-dropdown-trigger > div > div.right-container.style-scope.ytcp-dropdown-trigger > tp-yt-iron-icon"
);

However, this succeeds, and the expected drop down menu is revealed.

await page.evaluate(() => {
  let el: HTMLElement = document.querySelector(
    "#trigger > ytcp-dropdown-trigger > div > div.right-container.style-scope.ytcp-dropdown-trigger > tp-yt-iron-icon"
  );
  el.click();
});

I would prefer the first one to work, and since they are both using the same selector I am not sure why it is not working.

Youtube has alot of JS on this page, and I am thinking that this unexpected behavior is site-specific. Even if I use page.evaluate to click the dropdown arrow, and then wait for another expected element to be in the DOM, and then click that element, the click of the drop down menu item is not registering. I tried with both page.click(...) and page.evaluate(...) for the drop down menu item.

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