{"record":{"id":"1d2c39828ba206e6","repo":"microsoft/playwright","slug":"selectors-register-name-selector-engine-has","errorCode":null,"errorMessage":"selectors.register: \"${name}\" selector engine has been already registered","messagePattern":"selectors\\.register: \"(.+?)\" selector engine has been already registered","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/client/selectors.ts","lineNumber":33,"sourceCode":" */\n\nimport { evaluationScript } from './clientHelper';\nimport { setTestIdAttribute } from './locator';\nimport { kNoTimeout } from './timeoutSettings';\n\nimport type { SelectorEngine } from './types';\nimport type * as api from '../../types/types';\nimport type * as channels from './channels';\nimport type { BrowserContext } from './browserContext';\n\nexport class Selectors implements api.Selectors {\n  private _selectorEngines: channels.SelectorEngine[] = [];\n  private _testIdAttributeName: string | undefined;\n  readonly _contextsForSelectors = new Set<BrowserContext>();\n\n  async register(name: string, script: string | (() => SelectorEngine) | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {\n    if (this._selectorEngines.some(engine => engine.name === name))\n      throw new Error(`selectors.register: \"${name}\" selector engine has been already registered`);\n\n    const source = await evaluationScript(script, undefined, false);\n    const selectorEngine: channels.SelectorEngine = { ...options, name, source };\n    for (const context of this._contextsForSelectors)\n      await context._channel.registerSelectorEngine({ selectorEngine }, kNoTimeout);\n    this._selectorEngines.push(selectorEngine);\n  }\n\n  setTestIdAttribute(attributeName: string) {\n    this._testIdAttributeName = attributeName;\n    setTestIdAttribute(attributeName);\n    for (const context of this._contextsForSelectors) {\n      context._options.testIdAttributeName = attributeName;\n      context._channel.setTestIdAttributeName({ testIdAttributeName: attributeName }, kNoTimeout).catch(() => {});\n    }\n  }\n\n  _withSelectorOptions<T>(options: T) {","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/client/selectors.ts#L15-L51","documentation":"Error \"selectors.register: \"${name}\" selector engine has been already registered\" thrown in microsoft/playwright.","triggerScenarios":"Thrown at packages/playwright-core/src/client/selectors.ts:33 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"}