I want to click the Facebook's Photo/video button when creating a post. The element is:
<div aria-label="Photo/video" aria-pressed="false" class="..." role="button" tabindex="0">
<div><div><div class="..."><div class="..."><div class="...">
<img class="..." alt="" src="https://static.xx.fbcdn.net/rsrc.php/v3/y7/r/Ivw7nhRtXyo.png?_nc_eui2=AeHY6dd2udiKCsGGc3_l3Lj2PL4YoeGsw5I8vhih4azDks5jrq6FoGG-iYDYkCJ4e3z08U_itrGNYjc5wzxwesxH" style="height: 24px; width: 24px;">
</div><div class="..." role="none" data-visualcompletion="ignore" style="inset: 0px;"></div></div></div></div><div><div></div></div></div></div>
According to Page interactions | Puppeteer, I think the correct code is:
await page.locator('::-p-aria([name="Photo/video"][role="button"])').click();
But it doesn't click. Changing name
to label
doesn't help. Do you know how to make it work?
Psuedoselectors do not currently work. Use an * or whatever element tag.
await page.locator('*[aria-label="Photo/video"][role="button"]')