Skip to main content
Version: 23.8.0

Accessibility 类

¥Accessibility class

Accessibility 类提供了检查浏览器的辅助功能树的方法。可访问性树由 屏幕阅读器switches 等辅助技术使用。

¥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's rendering engine - 有一个 "可达性树" 的概念,然后将其转换为不同平台特定的 API。Accessibility 命名空间使用户可以访问 Blink Accessibility Tree。

¥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 尝试近似此过滤,仅公开树的 "interesting" 节点。

¥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

方法

修饰符

描述

snapshot(options)

捕获可访问性树的当前状态。返回的对象表示页面的根可访问节点。

评论:

注意 Chrome 辅助功能树包含大多数平台和大多数屏幕阅读器都未使用的节点。Puppeteer 也会丢弃它们,以便更容易处理树,除非 interestingOnly 设置为 false