puppeteer-jquery icon indicating copy to clipboard operation
puppeteer-jquery copied to clipboard

Clicking a Dynamic Element

Open jasondalycan opened this issue 2 years ago • 3 comments

Hi how do you click an element added dynamically to the page? For example, if an element is added via JavaScript after the page is loaded the code page.jQuery(selector).trigger("click") doesn't find the element and results in an error.

jasondalycan avatar May 03 '22 23:05 jasondalycan

page.jQuery(selector).trigger("click") just emit a click event and is, far from a real click, and they work for dynamique elements.

Puppeteer and Playwright click functions should be used by default and should work with a dynamic element.

I'm using my own automation framework now, puppeteer-jquery is the first step to migrating to Playwright.

UrielCh avatar May 04 '22 04:05 UrielCh

page.jQuery(selector).trigger("click") Is the above code supposed to work then on dynamic elements @UrielCh ? When I'm trying this code it only works on static objects (i.e. part of the DOM at page render time).

jasondalycan avatar May 04 '22 20:05 jasondalycan

ok, provide a full sample. I will test is / fix it and add it as a sample.

UrielCh avatar May 05 '22 04:05 UrielCh