@@ -22,28 +22,38 @@ export default class VscodeOperator {
2222 */
2323 static async executeCommand ( page : Page , command : string ) : Promise < void > {
2424 await page . keyboard . press ( VSCode . CMD_PALETTE_KEY ) ;
25- await page . waitForTimeout ( Timeout . CLICK ) ;
26- const input = page . getByRole ( VSCode . CMD_PALETTE_ROLE , { name : VSCode . CMD_PALETTE_INPUT_NAME } ) ;
25+ // Wait for the quick-input widget to appear
26+ const input = page . locator ( ".quick-input-widget input.input" ) ;
27+ await input . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
2728 await input . fill ( command ) ;
2829 await page . waitForTimeout ( Timeout . CLICK ) ;
29- // Press Enter on the first matching option
30- await page . getByRole ( VSCode . LISTBOX_ROLE ) . first ( ) . press ( VSCode . ENTER ) ;
30+ // Press Enter on the first matching option in the list
31+ const firstOption = page . locator ( ".quick-input-widget .quick-input-list .monaco-list-row" ) . first ( ) ;
32+ if ( await firstOption . isVisible ( { timeout : 3_000 } ) . catch ( ( ) => false ) ) {
33+ await firstOption . click ( ) ;
34+ } else {
35+ await input . press ( VSCode . ENTER ) ;
36+ }
3137 await page . waitForTimeout ( Timeout . CLICK ) ;
3238 }
3339
3440 /**
3541 * Select a quick-pick option by its visible label text.
3642 */
3743 static async selectQuickPickItem ( page : Page , label : string ) : Promise < void > {
38- await page . getByRole ( VSCode . OPTION_ROLE , { name : label } ) . locator ( VSCode . LINK ) . click ( ) ;
44+ const option = page . locator ( ".quick-input-widget .quick-input-list .monaco-list-row" , { hasText : label } ) ;
45+ await option . first ( ) . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
46+ await option . first ( ) . click ( ) ;
3947 await page . waitForTimeout ( Timeout . CLICK ) ;
4048 }
4149
4250 /**
4351 * Select a quick-pick option by its zero-based index.
4452 */
4553 static async selectQuickPickIndex ( page : Page , index : number ) : Promise < void > {
46- await page . getByRole ( VSCode . OPTION_ROLE ) . nth ( index ) . locator ( VSCode . LINK ) . click ( ) ;
54+ const option = page . locator ( ".quick-input-widget .quick-input-list .monaco-list-row" ) . nth ( index ) ;
55+ await option . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
56+ await option . click ( ) ;
4757 await page . waitForTimeout ( Timeout . CLICK ) ;
4858 }
4959
0 commit comments