Skip to content

Instantly share code, notes, and snippets.

@mfairchild365
Last active October 13, 2020 20:08
Show Gist options
  • Save mfairchild365/742f249474dcba741874f09622859c35 to your computer and use it in GitHub Desktop.
Save mfairchild365/742f249474dcba741874f09622859c35 to your computer and use it in GitHub Desktop.
Automating screen reader

Scenario: I want to tell the screen reader to use down arrow until it reaches the end of element x?

JAWS: has its own cursor stop and the end boundary AFTER the last list item and BEFORE following content NVDA: does NOT have its own cursor stop. It exits the list and announces "out of list "

Given this example HTML

<p>content before</p>

<ol id="target">
    <li>
        Cats
        <ol>
            <li>Big cat</li>
            <li>Small cat</li>
        </ol>
    </li>
    <li>
        Dogs
    </li>
    <li>
        Birds
    </li>
</ol>
<p>content after</p>

Can I do something like:

automation.get(url); //page load (could return sr output of the entire page load action). cursor and keyboard focus will be at top of page.
let speechOutputCollection = automation.navigateToEndOf('#target').using(DOWN_ARROW).

assert(speechOutputCollection[speechOutputCollection.length-1].contains('out of list'), 'should convey the end boundary of the list');

Is something like this possible? automation.navigateToEndOf('#target') - is it possible to use a query selector to determine where the SR cursor is?

Ideas from @westont

automation.os.a11y.findNode({ type: "list", childCount: 3 });
automation.os.a11y.findNode(node => {
 if (node.type === "list" && node.childCount === 3) {
   if (node.children[0].name === "Cats") {
     return true;
   }
 }
 return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment