garrytan/gstack · error · Error

Element not found: ${selector}

Error message

Element not found: ${selector}

What it means

Error "Element not found: ${selector}" thrown in garrytan/gstack.

Source

Thrown at browse/src/cdp-inspector.ts:247

export async function inspectElement(
  page: Page,
  selector: string,
  options?: { includeUA?: boolean }
): Promise<InspectorResult> {
  const session = await getOrCreateSession(page);

  // Get document root
  const { root } = await session.send('DOM.getDocument', { depth: 0 });

  // Query for the element
  let nodeId: number;
  try {
    const result = await session.send('DOM.querySelector', {
      nodeId: root.nodeId,
      selector,
    });
    nodeId = result.nodeId;
    if (!nodeId) throw new Error(`Element not found: ${selector}`);
  } catch (err: any) {
    throw new Error(`Element not found: ${selector} — ${err.message}`);
  }

  // Get element attributes
  const { node } = await session.send('DOM.describeNode', { nodeId, depth: 0 });
  const tagName = (node.localName || node.nodeName || '').toLowerCase();
  const attrPairs = node.attributes || [];
  const attributes: Record<string, string> = {};
  for (let i = 0; i < attrPairs.length; i += 2) {
    attributes[attrPairs[i]] = attrPairs[i + 1];
  }
  const id = attributes.id || null;
  const classes = attributes.class ? attributes.class.split(/\s+/).filter(Boolean) : [];

  // Get box model
  let boxModel = {
    content: { x: 0, y: 0, width: 0, height: 0 },

View on GitHub (pinned to 94993f7401)

When it happens

Trigger: Thrown at browse/src/cdp-inspector.ts:247 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/79da8d40c927e54c. Report an issue: GitHub.