Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

367
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda