microsoft/playwright · error · Error

"name" attribute must be a string or a regular expression

Error message

"name" attribute must be a string or a regular expression

What it means

Error ""name" attribute must be a string or a regular expression" thrown in microsoft/playwright.

Source

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

        // Level is a number, convert it from string.
        if (typeof attr.value === 'string')
          attr.value = +attr.value;
        if (attr.op !== '=' || typeof attr.value !== 'number' || Number.isNaN(attr.value))
          throw new Error(`"level" attribute must be compared to a number`);
        options.level = attr.value;
        break;
      }
      case 'disabled': {
        validateSupportedValues(attr, [true, false]);
        validateSupportedOp(attr, ['<truthy>', '=']);
        options.disabled = attr.op === '<truthy>' ? true : attr.value;
        break;
      }
      case 'name': {
        if (attr.op === '<truthy>')
          throw new Error(`"name" attribute must have a value`);
        if (typeof attr.value !== 'string' && !(attr.value instanceof RegExp))
          throw new Error(`"name" attribute must be a string or a regular expression`);
        options.name = attr.value;
        options.nameOp = attr.op;
        options.nameExact = attr.caseSensitive;
        break;
      }
      case 'description': {
        if (attr.op === '<truthy>')
          throw new Error(`"description" attribute must have a value`);
        if (typeof attr.value !== 'string' && !(attr.value instanceof RegExp))
          throw new Error(`"description" attribute must be a string or a regular expression`);
        options.description = attr.value;
        options.descriptionOp = attr.op;
        options.descriptionExact = attr.caseSensitive;
        break;
      }
      case 'include-hidden': {
        validateSupportedValues(attr, [true, false]);
        validateSupportedOp(attr, ['<truthy>', '=']);

View on GitHub (pinned to c8fc3bf8d3)

When it happens

Trigger: Thrown at packages/injected/src/roleSelectorEngine.ts:113 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/392e2eaf8d096dde. Report an issue: GitHub.