diff --git a/src/runner/at-driver.js b/src/runner/at-driver.js index e55cd3f..60973d2 100644 --- a/src/runner/at-driver.js +++ b/src/runner/at-driver.js @@ -3,6 +3,14 @@ import ws from 'ws'; import { iterateEmitter } from '../shared/iterate-emitter.js'; import { RunnerMessage } from './messages.js'; +const globalSettings = { + JAWS: [ + { name: 'jcf:default:HTML:SayAllOnDocumentLoad', value: '0' }, + { name: 'jcf:default:options:TypingEcho', value: '0' }, + { name: 'jcf:default:options:DisplayStartupWizard', value: '0' }, + ], +}; + /** * @param {object} options * @param {object} [options.url] @@ -24,6 +32,8 @@ export async function createATDriver({ const socket = new ws(url); const driver = new ATDriver({ socket, log }); await driver.ready; + const settings = globalSettings[(await driver.getCapabilities()).atName]; + if (settings) await driver.setSettings(settings); abortSignal.then(() => driver.quit()); return driver; } @@ -64,6 +74,9 @@ export class ATDriver { this._nextId = 0; } + /** + * @returns {Promise<{atName: string, atVersion:string, platformName: string}>} + */ async getCapabilities() { await this.ready; return this._capabilities; @@ -128,6 +141,16 @@ export class ATDriver { } } } + + /** + * + * @param {[{name: string, value: string | boolean}]} settings + */ + async setSettings(settings) { + const { atName } = await this.getCapabilities(); + const method = atName == 'nvda' ? 'nvda:settings.setSettings' : 'settings.setSettings'; + return this._send({ method, params: { settings } }); + } } // https://w3c.github.io/webdriver/#keyboard-actions diff --git a/src/runner/driver-test-runner.js b/src/runner/driver-test-runner.js index 52cfe26..69b79f6 100644 --- a/src/runner/driver-test-runner.js +++ b/src/runner/driver-test-runner.js @@ -156,10 +156,9 @@ export class DriverTestRunner { if (atName == 'NVDA') { // disable the "beeps" when switching focus/browse mode, forces it to speak the mode after switching - await this.atDriver._send({ - method: 'nvda:settings.setSettings', - params: { settings: [{ name: 'virtualBuffers.passThroughAudioIndication', value: false }] }, - }); + await this.atDriver.setSettings([ + { name: 'virtualBuffers.passThroughAudioIndication', value: false }, + ]); try { for (const setting of settingsArray) { @@ -182,12 +181,9 @@ export class DriverTestRunner { } } finally { // turn the "beeps" back on so mode switches won't be spoken (default setting) - await this.atDriver._send({ - method: 'nvda:settings.setSettings', - params: { - settings: [{ name: 'virtualBuffers.passThroughAudioIndication', value: true }], - }, - }); + await this.atDriver.setSettings([ + { name: 'virtualBuffers.passThroughAudioIndication', value: true }, + ]); } } else if (atName == 'JAWS') { for (const setting of settingsArray) { @@ -211,12 +207,7 @@ export class DriverTestRunner { // set the setting and collect the mode switch utterance if we are in the incorrect mode. let unknownCollected = ''; const speechResponse = await this._collectSpeech(this.timesOption.modeSwitch, () => - this.atDriver._send({ - method: 'settings.setSettings', - params: { - settings: [{ name: 'cursor', value }], - }, - }) + this.atDriver.setSettings([{ name: 'cursor', value }]) ); while (speechResponse.length) { const lastMessage = speechResponse.shift().trim();