Assistive-Webdriver

Home > assistive-webdriver > addScreenReaderTextListener

addScreenReaderTextListener() function

Registers a listener function to be called each time a new message is coming from the screen reader.

Signature:

export declare function addScreenReaderTextListener(webdriver: WebdriverLike, fn: (message: string) => void, scope?: any): () => void;

Parameters

Parameter Type Description
webdriver WebdriverLike reference to the selenium-webdriver instance
fn (message: string) => void function to register as a listener. The message read by the screen reader is passed as the first (and only) parameter.
scope any scope to use when calling the listener

Returns:

() => void

a function to unregister the listener

Remarks

The function may not be called immediately after the screen reader reads a message. Messages are retrieved from the assistive-webdriver server only when refreshScreenReaderText() is called, and that is when the listeners are called if new messages are retrieved.