{"record":{"id":"5a72649d6aa8d902","repo":"garrytan/gstack","slug":"usage-browse-click-selector","errorCode":null,"errorMessage":"Usage: browse click <selector>","messagePattern":"Usage: browse click <selector>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/write-commands.ts","lineNumber":327,"sourceCode":"      }\n      const peekStr = peek.toString('utf8').trimStart();\n      // Valid markup opener: '<' followed by alpha (tag), '!' (doctype/comment), or '?' (xml prolog)\n      const looksLikeMarkup = /^<[a-zA-Z!?]/.test(peekStr);\n      if (!looksLikeMarkup) {\n        const hexDump = Array.from(buf.slice(0, 16)).map(b => b.toString(16).padStart(2, '0')).join(' ');\n        throw new Error(\n          `load-html: ${absolutePath} has ${ext} extension but content does not look like HTML. First bytes: ${hexDump}`\n        );\n      }\n\n      const html = buf.toString('utf8');\n      await session.setTabContent(html, { waitUntil });\n      return `Loaded HTML: ${absolutePath} (${stat.size} bytes)`;\n    }\n\n    case 'click': {\n      const selector = args[0];\n      if (!selector) throw new Error('Usage: browse click <selector>');\n\n      // Auto-route: if ref points to a real <option> inside a <select>, use selectOption\n      const role = session.getRefRole(selector);\n      if (role === 'option') {\n        const resolved = await session.resolveRef(selector);\n        if ('locator' in resolved) {\n          const optionInfo = await resolved.locator.evaluate(el => {\n            if (el.tagName !== 'OPTION') return null; // custom [role=option], not real <option>\n            const option = el as HTMLOptionElement;\n            const select = option.closest('select');\n            if (!select) return null;\n            return { value: option.value, text: option.text };\n          });\n          if (optionInfo) {\n            await resolved.locator.locator('xpath=ancestor::select').selectOption(optionInfo.value, { timeout: 5000 });\n            return `Selected \"${optionInfo.text}\" (auto-routed from click on <option>) → now at ${page.url()}`;\n          }\n          // Real <option> with no parent <select> or custom [role=option] — fall through to normal click","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L309-L345","documentation":"Error \"Usage: browse click <selector>\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/write-commands.ts:327 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}