microsoft/playwright · error · Error
"level" attribute must be compared to a number
Error message
"level" attribute must be compared to a number
What it means
Error ""level" attribute must be compared to a number" thrown in microsoft/playwright.
Source
Thrown at packages/injected/src/roleSelectorEngine.ts:99
validateSupportedValues(attr, [true, false]);
validateSupportedOp(attr, ['<truthy>', '=']);
options.selected = attr.op === '<truthy>' ? true : attr.value;
break;
}
case 'expanded': {
validateSupportedRole(attr.name, kAriaExpandedRoles, role);
validateSupportedValues(attr, [true, false]);
validateSupportedOp(attr, ['<truthy>', '=']);
options.expanded = attr.op === '<truthy>' ? true : attr.value;
break;
}
case 'level': {
validateSupportedRole(attr.name, kAriaLevelRoles, role);
// 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;View on GitHub (pinned to c8fc3bf8d3)
When it happens
Trigger: Thrown at packages/injected/src/roleSelectorEngine.ts:99 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/4cdaa1c644e148b1.
Report an issue: GitHub.