test: add 'getByTestId with custom testId should work' (#17966)

This commit is contained in:
Max Schmitt 2022-10-10 22:17:38 +03:00 committed by GitHub
parent a62a67fba3
commit 70258d9c49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');