microsoft/playwright · error · Error

Role must not be empty

Error message

Role must not be empty

What it means

Error "Role must not be empty" thrown in microsoft/playwright.

Source

Thrown at packages/injected/src/roleSelectorEngine.ts:212

    for (const element of root.querySelectorAll('*')) {
      match(element);
      if (element.shadowRoot)
        shadows.push(element.shadowRoot);
    }
    shadows.forEach(query);
  };

  query(scope);
  return result;
}

export function createRoleEngine(internal: boolean): SelectorEngine {
  return {
    queryAll: (scope: SelectorRoot, selector: string): Element[] => {
      const parsed = parseAttributeSelector(selector, true);
      const role = parsed.name.toLowerCase();
      if (!role)
        throw new Error(`Role must not be empty`);
      const options = validateAttributes(parsed.attributes, role);
      beginAriaCaches();
      try {
        return queryRole(scope, options, internal);
      } finally {
        endAriaCaches();
      }
    }
  };
}

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/injected/src/roleSelectorEngine.ts:212 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/db8fd445489dc0ec. Report an issue: GitHub.