@@ -19,38 +19,20 @@ export default class JavaOperator {
1919 /**
2020 * Waits for the Java Language Server to finish indexing.
2121 *
22- * Strategy: we click the language-status area in the status bar, which
23- * opens a hover showing codicon-thumbsup / codicon-pass when the LS is
24- * ready. We poll this until we see one of those icons.
25- *
26- * Falls back to checking for "Java" text + "Ready" if the icon approach
27- * doesn't match (VS Code version variance).
22+ * Strategy: poll the status bar for a button whose accessible name
23+ * contains "Java: Ready" (e.g. "coffee Java: Ready, Show Java status menu").
24+ * This is more reliable than clicking a hover because it doesn't depend
25+ * on internal VS Code DOM IDs that vary across versions.
2826 */
2927 static async waitForJavaLSReady ( page : Page , timeoutMs = Timeout . JAVA_LS_READY ) : Promise < void > {
3028 // Give the extension a moment to register its status bar item
3129 await page . waitForTimeout ( Timeout . EXTENSION_ACTIVATE ) ;
3230
3331 await expect . poll ( async ( ) => {
3432 try {
35- // Try clicking the language status area
36- const langStatus = page . locator ( '[id="status.languageStatus"]' ) ;
37- if ( await langStatus . isVisible ( ) . catch ( ( ) => false ) ) {
38- await langStatus . click ( ) ;
39- await page . waitForTimeout ( 500 ) ;
40-
41- // Check for "ready" icons in the hover
42- const readyIcon = page . locator (
43- ".context-view .hover-language-status .codicon-thumbsup, " +
44- ".context-view .hover-language-status .codicon-pass"
45- ) ;
46- if ( await readyIcon . first ( ) . isVisible ( ) . catch ( ( ) => false ) ) {
47- // Dismiss the hover by pressing Escape
48- await page . keyboard . press ( VSCode . ESCAPE ) ;
49- return "ready" ;
50- }
51-
52- // Dismiss the hover
53- await page . keyboard . press ( VSCode . ESCAPE ) ;
33+ const javaReadyButton = page . getByRole ( VSCode . BUTTON_ROLE , { name : / J a v a : \s * R e a d y / i } ) ;
34+ if ( await javaReadyButton . isVisible ( ) . catch ( ( ) => false ) ) {
35+ return "ready" ;
5436 }
5537 return "not-ready" ;
5638 } catch {
0 commit comments