Skip to main content

IScreenReader

Abstract base interface for screen reader classes.

See also:

Contents:

screenReader.name​

Getter for the screen reader name.

Returns: string

screenReader.version​

Getter for the screen reader version.

Returns: string

screenReader.act([options])​

Perform the default action for the item in the screen reader cursor.

Parameters:

Returns: Promise<void>

screenReader.capture(action[, options])​

Capture screen reader output produced while an action runs. The action can be performed using an external automation tool such as Playwright. The returned capture contains the action's result and the screen reader output associated with the action.

Parameters:

  • action () => Promise<T> The action to perform while capturing screen reader output.
  • Optional: options CommandOptions Capture options.

Returns: Promise<Capture<T>> The action's result and captured screen reader output.

screenReader.clearItemTextLog()​

Clear the log of all visited item text for this screen reader instance.

Returns: Promise<void>

screenReader.clearSpokenPhraseLog()​

Clear the log of all spoken phrases for this screen reader instance.

Returns: Promise<void>

screenReader.click([options])​

Click the mouse.

Parameters:

Returns: Promise<void>

screenReader.default()​

Detect whether the screen reader is the default screen reader for the current OS.

Returns: boolean

screenReader.detect()​

Detect whether the screen reader is supported for the current OS.

Returns: boolean

screenReader.getSetting(key)​

Returns the value of a setting for this screen reader instance.

Parameters:

  • key string The setting name.

Returns: unknown The setting value.

screenReader.getSettings()​

Returns all the current settings for this screen reader instance.

Returns: Record<string, unknown> Current settings values.

screenReader.interact([options])​

Interact with the item under the screen reader cursor.

Parameters:

Returns: Promise<void>

screenReader.itemText()​

Get the text of the item in the screen reader cursor.

Returns: Promise<string> The item's text.

screenReader.itemTextLog()​

Get the log of all visited item text for this screen reader instance.

Returns: Promise<Array<string>> The item text log.

screenReader.lastSpokenPhrase()​

Get the last spoken phrase.

Returns: Promise<string> The last spoken phrase.

screenReader.navigateNextUntil(matcher[, options])​

Move the screen reader cursor to the next location until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

screenReader.navigateNextHeadingUntil(matcher[, options])​

Move the screen reader cursor to the next heading until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

screenReader.navigateNextLandmarkUntil(matcher[, options])​

Move the screen reader cursor to the next landmark until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

Move the screen reader cursor to the next link until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

screenReader.navigatePreviousUntil(matcher[, options])​

Move the screen reader cursor to the previous location until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

screenReader.navigatePreviousHeadingUntil(matcher[, options])​

Move the screen reader cursor to the previous heading until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

screenReader.navigatePreviousLandmarkUntil(matcher[, options])​

Move the screen reader cursor to the previous landmark until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

Move the screen reader cursor to the previous link until its spoken phrase matches the provided matcher.

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

screenReader.next([options])​

Move the screen reader cursor to the next location.

Parameters:

Returns: Promise<void>

screenReader.nextHeading([options])​

Move the screen reader cursor to the next heading.

Parameters:

Returns: Promise<void>

screenReader.nextLandmark([options])​

Move the screen reader cursor to the next landmark.

Parameters:

Returns: Promise<void>

Move the screen reader cursor to the next link.

Parameters:

Returns: Promise<void>

screenReader.perform(command[, options])​

Perform a screen reader command.

Parameters:

Returns: Promise<void>

screenReader.press(key[, options])​

Press a key on the focused item.

key can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the key values can be found on the MDN key values page. Examples of the keys are:

F1 - F20, Digit0 - Digit9, KeyA - KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp, etc.

Following modification shortcuts are also supported: Shift, Control, Alt, Meta.

Holding down Shift will type the text that corresponds to the key in the upper case.

If key is a single character, it is case-sensitive, so the values a and A will generate different respective texts.

Shortcuts such as key: "Control+f" or key: "Control+Shift+f" are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.

Parameters:

  • key string Name of the key to press or a character to generate, such as ArrowLeft or a.
  • Optional: options KeyboardOptions Additional options.

Returns: Promise<void>

screenReader.previous([options])​

Move the screen reader cursor to the previous location.

Parameters:

Returns: Promise<void>

screenReader.previousHeading([options])​

Move the screen reader cursor to the previous heading.

Parameters:

Returns: Promise<void>

screenReader.previousLandmark([options])​

Move the screen reader cursor to the previous landmark.

Parameters:

Returns: Promise<void>

Move the screen reader cursor to the previous link.

Parameters:

Returns: Promise<void>

screenReader.spokenPhraseLog()​

Get the log of all spoken phrases for this screen reader instance.

Returns: Promise<Array<string>> The spoken phrase log.

screenReader.start([options])​

Turn the screen reader on.

Parameters:

Returns: Promise<void>

screenReader.stop([options])​

Turn the screen reader off.

Parameters:

Returns: Promise<void>

screenReader.stopInteracting([options])​

Stop interacting with the current item.

Parameters:

Returns: Promise<void>

screenReader.type(text[, options])​

Type text into the focused item.

To press a special key, like Control or ArrowDown, use screenReader.press(key[, options]).

Parameters:

  • text string Text to type into the focused item.
  • Optional: options CommandOptions Additional options.

Returns: Promise<void>