admin管理员组文章数量:1335560
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=".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?
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/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?
- 1 Psuedoselectors do not currently work. Use an * or whatever element tag. await page.locator('*[aria-label="Photo/video"][role="button"]') – jakob_a Commented Nov 20, 2024 at 17:36
- this works. Is it a bug? – Ooker Commented Nov 21, 2024 at 5:52
- You can't use the "::-p-aria" part. – jakob_a Commented Nov 22, 2024 at 13:53
1 Answer
Reset to default 1Psuedoselectors do not currently work. Use an * or whatever element tag.
await page.locator('*[aria-label="Photo/video"][role="button"]')
本文标签: javascriptHow to click an aria button with PuppeteerStack Overflow
版权声明:本文标题:javascript - How to click an aria button with Puppeteer? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742345277a2457397.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论