I have a button nested in this video player that I am trying to simply click. Any idea how do I select?
await page.waitForSelector('.icon-play');
await page.click('.icon-play');
await page.waitFor(6000);
<a tabindex="-1" href="#" role="button" class="icon-play comp largePlayBtn largePlayBtnBorder" aria-label="Play clip" data-order="1" data-plugin-name="largePlayBtn" style="display: block;"></a>
I had the same problem a while back. A nested link inside a image.
This is due to the fact that the element needs to be visually clickable. You can perform a simple javascript click action using the HTMLElement.click()
to bypass the puppeteer click action.
page.$eval(`HTMLElementSelector`, element =>
element.click()
);
As you're clicking a link, which implies navigation you would want to englobe that inside a promise. Something like that should do the trick.
await Promise.all([
page.$eval(`HTMLElementSelector`, element =>
element.click()
),
await page.waitForNavigation(),
]);