{"record":{"id":"ba0dae3e6b544ea6","repo":"microsoft/playwright","slug":"attr-attribute-is-only-supported-for-roles","errorCode":null,"errorMessage":"\"${attr}\" attribute is only supported for roles: ${roles.slice().sort().map(role => `\"${role}\"`).join(', ')}","messagePattern":"\"(.+?)\" attribute is only supported for roles: (.+?)\"`\\)\\.join\\(', '\\)\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/injected/src/roleSelectorEngine.ts","lineNumber":48,"sourceCode":"  descriptionExact?: boolean;\n  name?: string | RegExp;\n  nameOp?: Exclude<AttributeSelectorOperator, '<truthy>'>;\n  nameExact?: boolean;\n  checked?: boolean | 'mixed';\n  pressed?: boolean | 'mixed';\n  selected?: boolean;\n  expanded?: boolean;\n  level?: number;\n  disabled?: boolean;\n  includeHidden?: boolean;\n};\n\nconst kSupportedAttributes = ['selected', 'checked', 'pressed', 'expanded', 'level', 'disabled', 'name', 'description', 'include-hidden'];\nkSupportedAttributes.sort();\n\nfunction validateSupportedRole(attr: string, roles: string[], role: string) {\n  if (!roles.includes(role))\n    throw new Error(`\"${attr}\" attribute is only supported for roles: ${roles.slice().sort().map(role => `\"${role}\"`).join(', ')}`);\n}\n\nfunction validateSupportedValues(attr: AttributeSelectorPart, values: any[]) {\n  if (attr.op !== '<truthy>' && !values.includes(attr.value))\n    throw new Error(`\"${attr.name}\" must be one of ${values.map(v => JSON.stringify(v)).join(', ')}`);\n}\n\nfunction validateSupportedOp(attr: AttributeSelectorPart, ops: AttributeSelectorOperator[]) {\n  if (!ops.includes(attr.op))\n    throw new Error(`\"${attr.name}\" does not support \"${attr.op}\" matcher`);\n}\n\nfunction validateAttributes(attrs: AttributeSelectorPart[], role: string): RoleEngineOptions {\n  const options: RoleEngineOptions = { role };\n  for (const attr of attrs) {\n    switch (attr.name) {\n      case 'checked': {\n        validateSupportedRole(attr.name, kAriaCheckedRoles, role);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/injected/src/roleSelectorEngine.ts#L30-L66","documentation":"Error \"\"${attr}\" attribute is only supported for roles: ${roles.slice().sort().map(role => `\"${role}\"`).join(', ')}\" thrown in microsoft/playwright.","triggerScenarios":"Thrown at packages/injected/src/roleSelectorEngine.ts:48 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":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}