{"record":{"id":"f0898dda2be149c3","repo":"vitest-dev/vitest","slug":"method-getbytext-is-not-supported-by-the-prov","errorCode":null,"errorMessage":"Method \"getByText\" is not supported by the \"${provider}\" provider.","messagePattern":"Method \"getByText\" is not supported by the \"(.+?)\" provider\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser/src/client/tester/context.ts","lineNumber":455,"sourceCode":"    })\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) {\n      (page as any)[key] = (methods as any)[key].bind(page)\n    }\n    return page\n  },\n}\n","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/browser/src/client/tester/context.ts#L437-L473","documentation":"page.getByText is a locator method only available with a full browser provider. The default page stub throws, naming the active provider. Text-based location needs provider selector engines (Playwright's text engine) which the preview provider does not provide.","triggerScenarios":"Calling page.getByText('Submit') while provider is 'preview' or any provider that has not registered the method via page.extend.","commonSituations":"i18n/content tests ported from Playwright or Testing Library; default provider config; partial provider registration.","solutions":["Switch test.browser.provider to 'playwright' or 'webdriverio'.","Under preview, locate via XPath or a text-walking helper (e.g. Array.from(document.querySelectorAll('*')).find(e => e.textContent?.includes('Submit'))).","Register the method yourself via page.extend for a custom provider."],"exampleFix":"// before\nconst node = page.getByText('Submit')\n// after (preview provider)\nconst node = Array.from(document.querySelectorAll('button, a, span')).find(e => e.textContent === 'Submit')!","handlingStrategy":"validation","validationCode":"if (getBrowserState().provider === 'preview') {\n  Array.from(document.querySelectorAll('*')).find(e => e.textContent === 'Submit')\n} else {\n  page.getByText('Submit')\n}","typeGuard":"function supportsLocators(): boolean {\n  return ['playwright', 'webdriverio'].includes(getBrowserState().provider ?? '')\n}","tryCatchPattern":null,"preventionTips":["Use a full provider for text-based location.","Provide a text-walk fallback under preview.","Keep provider-specific code paths documented."],"tags":["browser","locators","provider","preview"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}