最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to click an element using a node ID from the accessibility tree in Puppeteer? - Stack Overflow

programmeradmin2浏览0评论

I’m working with Puppeteer to automate interactions on a webpage. I have retrieved information from the accessibility tree using Puppeteer’s page.accessibility.snapshot() method. The snapshot provides elements with unique id values, but these IDs do not correspond to regular HTML attributes. I want to programmatically click on an element using its node ID from this snapshot.

Here’s what I’ve tried so far:

  • I used page.accessibility.snapshot() to retrieve the accessibility tree and find the node ID.
  • Attempted to use page.evaluate() with the retrieved id, but it’s unclear how to map this back to the actual DOM element.
  • Explored using ARIA roles (role: "button") and names (name: "Recherche Google"), but this doesn’t guarantee matching the specific node.

I expected to interact with the element using the node ID or any accessible path, but I haven’t found a reliable way to map the accessibility node ID to a clickable element in Puppeteer.

发布评论

评论列表(0)

  1. 暂无评论