Home > assistive-playwright-client
assistive-playwright-client package
This package contains functions to be used with playwright in order to test a web application with a screen reader.
Classes
Class |
Description |
CalibrationError |
Object that is thrown by playwrightCalibrate() if the calibration process fails because the position of the browser viewport cannot be detected on the screen of the virtual machine. |
CalibrationResult |
Result of the calibration, returned by playwrightCalibrate(), and allowing to translate coordinates relative to the top-left corner of the viewport, or coordinates relative to the center of a DOM element into screen coordinates. |
ScreenReaderClient |
Class giving access to messages from the screen reader. It is a simple wrapper around websocket that stores each incoming message and gives utility functions to wait for specific messages to come. |
VMKeyboard |
Object implementing the Keyboard interface from playwright, it can send low-level keyboard events to the virtual machine. |
VMMouse |
Object implementing the Mouse interface from playwright, it can send low-level mouse events to the virtual machine. |
Functions
Function |
Description |
calibrateMouseFunctionFactory(vm) |
Creates a mouse calibration function for the specified virtual machine. |
connectRemotePlaywright(url, localPlaywright) |
Connects to a remote assistive-playwright-server running at the given URL and returns the chromium, firefox and webkit playwright browser type objects allowing to start and control those browsers remotely. |
createVM(vmconfig) |
Clones and starts a virtual machine that contains assistive-playwright-server, and returns an object allowing to control playwright inside the virtual machine, send low-level keyboard and mouse events and receive messages from the screen reader. This is the main entry point of the assistive-playwright-client API. |
isMatch(screenReaderText, expectedText) |
Returns whether the text coming from the screen reader passed as the first parameter matches the expected text specified as the second parameter. |
playwrightCalibrate(vm, frame, options) |
Finds the coordinates of the viewport in the browser window. There is no playwright API for this, so it is done by displaying QR codes in the viewport and finding them in the screen capture. |
Interfaces
Interface |
Description |
CalibrationOptions |
Options for the calibration, passed to playwrightCalibrate(). |
RemotePlaywright |
Reference to objects implementing the BrowserType interface from playwright and allowing to start and control instances of chromium, firefox and webkit. This interface is returned from connectRemotePlaywright() and allows to remotely control those browsers with the Playwright API. |
VMConfiguration |
Virtual machine configuration. |
VMWithPlaywright |
Object allowing to control playwright inside the virtual machine, send low-level keyboard and mouse events and receive messages from the screen reader. |
Type Aliases
Type Alias |
Description |
CalibrateMouseFunction |
A mouse calibration function. This is returned by createVM() in the VMWithPlaywright object. The calibration process finds where the browser viewport is located on the screen, allowing to use coordinates relative to the viewport or to a DOM element instead of using screen coordinates. This function returns a VMMouse object that allows to easily send low-level mouse events to the virtual machine. |
ExpectedText |
Type of an expectation from a message coming from the screen reader. |