'How to double click in Puppeteer

I have a workspace in which I can add different objects. There is a scenario in which on double click, an object can be automatically added in the workspace. I have gone through different solutions but none of them really worked.

This is what I have tried:

await page.evaluate(selector => {
  var targLink = document.querySelector(selector);
  var clickEvent = document.createEvent('MouseEvents');
  clickEvent.initEvent('dblclick', true, true);
  targLink.dispatchEvent(clickEvent);
}, selector)


Solution 1:[1]

You can also just do:

await page.click(selector, { clickCount: 2 });

as mentioned here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Raz