Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: add 'getByTestId with custom testId should work' (#17966)
Max Schmitt70258d9c49b7
diff --git a/tests/page/selectors-get-by.spec.ts b/tests/page/selectors-get-by.spec.tsindex dba7978592..a54cbe237b 100644--- a/tests/page/selectors-get-by.spec.ts+++ b/tests/page/selectors-get-by.spec.ts@@ -23,6 +23,14 @@ it('getByTestId should work', async ({ page }) => {await expect(page.locator('div').getByTestId('Hello')).toHaveText('Hello world');});+it('getByTestId with custom testId should work', async ({ page, playwright }) => {+ await page.setContent('<div><div data-my-custom-testid="Hello">Hello world</div></div>');+ playwright.selectors.setTestIdAttribute('data-my-custom-testid');+ await expect(page.getByTestId('Hello')).toHaveText('Hello world');+ await expect(page.mainFrame().getByTestId('Hello')).toHaveText('Hello world');+ await expect(page.locator('div').getByTestId('Hello')).toHaveText('Hello world');+});+it('getByTestId should escape id', async ({ page }) => {await page.setContent(`<div><div data-testid='He"llo'>Hello world</div></div>`);await expect(page.getByTestId('He"llo')).toHaveText('Hello world');