From 70258d9c49b71cd5b396badf0374ccd9d998c5a0 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 10 Oct 2022 22:17:38 +0300 Subject: [PATCH] test: add 'getByTestId with custom testId should work' (#17966) --- tests/page/selectors-get-by.spec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/page/selectors-get-by.spec.ts b/tests/page/selectors-get-by.spec.ts index 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('
Hello world
'); + 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(`
Hello world
`); await expect(page.getByTestId('He"llo')).toHaveText('Hello world');