{"record":{"id":"a8708154900d6ea8","repo":"garrytan/gstack","slug":"element-not-found-selector-err-message","errorCode":null,"errorMessage":"Element not found: ${selector} — ${err.message}","messagePattern":"Element not found: (.+?) — (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/cdp-inspector.ts","lineNumber":249,"sourceCode":"  selector: string,\n  options?: { includeUA?: boolean }\n): Promise<InspectorResult> {\n  const session = await getOrCreateSession(page);\n\n  // Get document root\n  const { root } = await session.send('DOM.getDocument', { depth: 0 });\n\n  // Query for the element\n  let nodeId: number;\n  try {\n    const result = await session.send('DOM.querySelector', {\n      nodeId: root.nodeId,\n      selector,\n    });\n    nodeId = result.nodeId;\n    if (!nodeId) throw new Error(`Element not found: ${selector}`);\n  } catch (err: any) {\n    throw new Error(`Element not found: ${selector} — ${err.message}`);\n  }\n\n  // Get element attributes\n  const { node } = await session.send('DOM.describeNode', { nodeId, depth: 0 });\n  const tagName = (node.localName || node.nodeName || '').toLowerCase();\n  const attrPairs = node.attributes || [];\n  const attributes: Record<string, string> = {};\n  for (let i = 0; i < attrPairs.length; i += 2) {\n    attributes[attrPairs[i]] = attrPairs[i + 1];\n  }\n  const id = attributes.id || null;\n  const classes = attributes.class ? attributes.class.split(/\\s+/).filter(Boolean) : [];\n\n  // Get box model\n  let boxModel = {\n    content: { x: 0, y: 0, width: 0, height: 0 },\n    padding: { top: 0, right: 0, bottom: 0, left: 0 },\n    border: { top: 0, right: 0, bottom: 0, left: 0 },","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/cdp-inspector.ts#L231-L267","documentation":"Error \"Element not found: ${selector} — ${err.message}\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/cdp-inspector.ts:249 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"}