{"id":"2295b9141bf448aa","repo":"vitest-dev/vitest","slug":"method-getbyalttext-is-not-supported-by-the-p","errorCode":null,"errorMessage":"Method \"getByAltText\" is not supported by the \"${provider}\" provider.","messagePattern":"Method \"getByAltText\" is not supported by the \"(.+?)\" provider\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser/src/client/tester/context.ts","lineNumber":449,"sourceCode":"        [{\n          name,\n          stack: bodyOrOptions?.stack ?? error?.stack,\n        }],\n        error,\n      )\n    })\n  },\n  getByRole() {\n    throw new Error(`Method \"getByRole\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByLabelText() {\n    throw new Error(`Method \"getByLabelText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByTestId() {\n    throw new Error(`Method \"getByTestId\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByAltText() {\n    throw new Error(`Method \"getByAltText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByPlaceholder() {\n    throw new Error(`Method \"getByPlaceholder\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByText() {\n    throw new Error(`Method \"getByText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByTitle() {\n    throw new Error(`Method \"getByTitle\" is not supported by the \"${provider}\" provider.`)\n  },\n  elementLocator() {\n    throw new Error(`Method \"elementLocator\" is not supported by the \"${provider}\" provider.`)\n  },\n  frameLocator() {\n    throw new Error(`Method \"frameLocator\" is not supported by the \"${provider}\" provider.`)\n  },\n  extend(methods) {\n    for (const key in methods) {","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/browser/src/client/tester/context.ts#L431-L467","documentation":"page.getByAltText is a throwing stub (packages/browser/src/client/tester/context.ts:448-449). Alt-text queries are only available on Locator instances (getElementLocatorSelectors wires locator.getByAltText at context.ts:514). Calling the stub on page throws.","triggerScenarios":"Calling page.getByAltText('logo') directly on the page object without an extension.","commonSituations":"Image-heavy tests where developers expect a page-level getByAltText mirroring Playwright.","solutions":["Use a Locator: page.elementLocator(document.body).getByAltText('logo').","Register page.getByAltText via browser.locators.extend(...) for a top-level shortcut."],"exampleFix":"// before\nconst img = page.getByAltText('Company logo')\n// after\nconst img = page.elementLocator(document.body).getByAltText('Company logo')","handlingStrategy":"type-guard","validationCode":"const root = page.elementLocator(document.body)\nconst img = root.getByAltText('Company logo')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve alt-text queries through a Locator.","Add a page-level extension only if you have many call sites."],"tags":["browser","locators","getbyalttext","page","unsupported"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}