11import { test } from "@playwright/test" ;
2- import { voiceOver , macOSActivate } from "@guidepup/guidepup" ;
2+ import { voiceOver , macOSActivate , MacOSKeyCodes } from "@guidepup/guidepup" ;
33import type { CommandOptions , VoiceOver } from "@guidepup/guidepup" ;
44import { applicationNameMap } from "./applicationNameMap" ;
55
@@ -96,33 +96,36 @@ export const voiceOverTest = test.extend<{
9696 // Ensure application is brought to front and focused.
9797 await macOSActivate ( applicationName ) ;
9898
99+ // Cancel auto navigation
100+ await voiceOverPlaywright . perform ( { keyCode : MacOSKeyCodes . Control } ) ;
101+
99102 // Ensure the document is ready and focused.
100103 await page . bringToFront ( ) ;
101104 await page . locator ( "body" ) . waitFor ( ) ;
102- await page . locator ( "body" ) . focus ( ) ;
103- await page . locator ( "body" ) . click ( ) ;
104- await page . locator ( "body" ) . blur ( ) ;
105-
106- // Try to navigate into web content.
107- await voiceOverPlaywright . interact ( ) ;
108105
109- // Series of find previous commands to escape accidental interaction
110- // with sub-content of web content area.
111- await voiceOverPlaywright . perform (
112- voiceOverPlaywright . keyboardCommands . findPreviousHeading ,
113- ) ;
114- await voiceOverPlaywright . perform (
115- voiceOverPlaywright . keyboardCommands . findPreviousGraphic ,
116- ) ;
106+ // Open the web item rotor defaulting to window spots.
117107 await voiceOverPlaywright . perform (
118- voiceOverPlaywright . keyboardCommands . findPreviousPlainText ,
108+ voiceOverPlaywright . keyboardCommands . openWebItemRotor ,
119109 ) ;
120110
111+ // Filter by "content" - currently web content spots for all browsers
112+ // are prefixed by "Content -".
113+ await voiceOverPlaywright . type ( "content" ) ;
114+
115+ // Select the web content window spot.
116+ await voiceOverPlaywright . perform ( { keyCode : MacOSKeyCodes . Enter } ) ;
117+
118+ // Navigate into web content.
119+ await voiceOverPlaywright . interact ( ) ;
120+
121121 // Navigate to the beginning of the web content.
122122 await voiceOverPlaywright . perform (
123123 voiceOverPlaywright . keyboardCommands . moveToBeginningOfText ,
124124 ) ;
125125
126+ // Cancel auto navigation
127+ await voiceOverPlaywright . perform ( { keyCode : MacOSKeyCodes . Control } ) ;
128+
126129 if ( clearLogs ) {
127130 // Clear out logs.
128131 await voiceOverPlaywright . clearItemTextLog ( ) ;
@@ -132,6 +135,13 @@ export const voiceOverTest = test.extend<{
132135
133136 await voiceOverPlaywright . start ( voiceOverStartOptions ) ;
134137 await macOSActivate ( applicationName ) ;
138+
139+ // Cancel auto navigation
140+ await voiceOverPlaywright . perform (
141+ { keyCode : MacOSKeyCodes . Control } ,
142+ { capture : false } ,
143+ ) ;
144+
135145 await use ( voiceOverPlaywright ) ;
136146 } finally {
137147 try {
0 commit comments