{"record":{"id":"6f4f32cd04b29168","repo":"garrytan/gstack","slug":"selector-not-found-opts-selector","errorCode":null,"errorMessage":"Selector not found: ${opts.selector}","messagePattern":"Selector not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/snapshot.ts","lineNumber":154,"sourceCode":" * Take an accessibility snapshot and build the ref map.\n */\nexport async function handleSnapshot(\n  args: string[],\n  session: TabSession,\n  securityOpts?: { splitForScoped?: boolean },\n): Promise<string> {\n  const opts = parseSnapshotArgs(args);\n  const page = session.getPage();\n  // Frame-aware target for accessibility tree\n  const target = session.getActiveFrameOrPage();\n  const inFrame = session.getFrame() !== null;\n\n  // Get accessibility tree via ariaSnapshot\n  let rootLocator: Locator;\n  if (opts.selector) {\n    rootLocator = target.locator(opts.selector);\n    const count = await rootLocator.count();\n    if (count === 0) throw new Error(`Selector not found: ${opts.selector}`);\n  } else {\n    rootLocator = target.locator('body');\n  }\n\n  const ariaText = await rootLocator.ariaSnapshot();\n  if (!ariaText || ariaText.trim().length === 0) {\n    session.setRefMap(new Map());\n    return '(no accessible elements found)';\n  }\n\n  // Parse the ariaSnapshot output\n  const lines = ariaText.split('\\n');\n  const refMap = new Map<string, RefEntry>();\n  const output: string[] = [];\n  let refCounter = 1;\n\n  // Track role+name occurrences for nth() disambiguation\n  const roleNameCounts = new Map<string, number>();","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/snapshot.ts#L136-L172","documentation":"Error \"Selector not found: ${opts.selector}\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/snapshot.ts:154 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"}