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

359
Views
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
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!