Skip to main content
Version: 24.38.0

Accessibility 类

🌐 Accessibility class

Accessibility 类提供了用于检查浏览器可访问性树的方法。可访问性树被辅助技术使用,例如屏幕阅读器开关

🌐 The Accessibility class provides methods for inspecting the browser's accessibility tree. The accessibility tree is used by assistive technology such as screen readers or switches.

语法

🌐 Signature

export declare class Accessibility

附注

🌐 Remarks

无障碍性是一个非常依赖平台的事情。在不同的平台上,可能有不同的屏幕阅读器,其输出可能差异很大。

🌐 Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might have wildly different output.

Blink——Chrome 的渲染引擎——有一个“可访问性树”的概念,然后将其转换为不同平台特定的 API。可访问性命名空间使用户能够访问 Blink 可访问性树。

🌐 Blink - Chrome's rendering engine - has a concept of "accessibility tree", which is then translated into different platform-specific APIs. Accessibility namespace gives users access to the Blink Accessibility Tree.

在从 Blink AX 树转换为特定平台的 AX 树或由辅助技术本身进行转换时,大部分可访问性树会被过滤掉。默认情况下,Puppeteer 会尝试近似这种过滤,只公开树中“有趣”的节点。

🌐 Most of the accessibility tree gets filtered out when converting from Blink AX Tree to Platform-specific AX-Tree or by assistive technologies themselves. By default, Puppeteer tries to approximate this filtering, exposing only the "interesting" nodes of the tree.

这个类的构造函数被标记为内部。第三方代码不应直接调用构造函数或创建继承 Accessibility 类的子类。

🌐 The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Accessibility class.

方法

🌐 Methods

方法

🌐 Method

修饰符

🌐 Modifiers

描述

🌐 Description

snapshot(options)

捕获辅助功能树的当前状态。返回的对象表示页面的根辅助节点。

🌐 Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.

附注

注意 Chrome 可访问性树包含在大多数平台和大多数屏幕阅读器上未使用的节点。Puppeteer 也会丢弃它们,以便获得更易处理的树,除非将 interestingOnly 设置为 false